Quantcast

Got Homework?

Connect with other students for help. It's a free community.

  • across
    MIT Grad Student
    Online now
  • laura*
    Helped 1,000 students
    Online now
  • Hero
    College Math Guru
    Online now

Here's the question you clicked on:

55 members online
  • 0 replying
  • 0 viewing

JadeEyes Group Title

I've got these programs to write but I'm unable to make it work. Could you help me with the codes of these two pragrams. I'm using Dev C++ . If possible use <stdio.h> Library.

  • one year ago
  • one year ago

  • This Question is Closed
  1. JadeEyes Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    4. According to University regulations, the following mapping between a student’s final mark and the indicative classification of degree is provided for guidance of the board of examiners. >= 70 First Class Honours 60-69 Upper Second Class Honours 50-59 Lower Second Class Honours 40-49 Third Class Honours <40 Not an honours degree (There are other regulations that affect the degree classification.) Write a program to prompt the user to enter a mark as a floating point number. Check that the mark is in the range 0.0 – 100.0 and, if it is, display the indicative degree classification according to the mapping above and if not, then display a message saying that the marks input is invalid. Test your program to ensure that the mapping is correct. 5. The UK sequence of traffic lights is: "Red" (means stop); this is followed by: "Red and Amber" (means prepare to go); this is followed by: "Green" (means go); this is followed by: "Amber" (means prepare to stop); this is followed by: "Red"; etc.. Write a program that prompts the user to enter the current state of a traffic light, then displays the next state. For example, if the current state is "Red and Amber", the next state is "Green". Use a menu system to obtain the current. Thank You..!! :)

    • one year ago
  2. compute Group Title
    Best Response
    You've already chosen the best response.
    Medals 2

    //Program For question number 4... #include<iostream.h> void main() { float num; cout<<"Enter marks:"<<endl; cin>>num; if(num>=0.0 && num<=100.0) { if(num>=70.0) cout<<"First Class Honours"; else if(num>=60.0 && num<70.0) cout<<"Upper Second Class Honours"; else if(num>=50.0 && num<60.0) cout<<"Lower Second Class Honours"; else if(num>=40.0 && num<50.0) cout<<"Third Class Honours"; else if(num<40.0) cout<<"Not an honours degree"; } else { cout<<"Marks input is invalid"; } }

    • one year ago
  3. oldrin.bataku Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    No, no, please, never, no. I would avoid using Dev-C++ in favor of downloading the latest MinGW build of gcc or building clang yourself. Avoid doing what @compute advocated above, because not only should that code not work but it sets forth some very bad practices. Always declare main to be int and use the standard includes i.e. <iostream> not <iostream.h>. Anyways, since you should use standard includes, remember that all the members are in the std namespace... though, actually, very little of that was relevant, since you appear to be a C programmer (hence <stdio.h>). Again, I urge you to just download the MinGW build of gcc or build clang, as both are more-or-less C99-compliant compilers.

    • one year ago
  4. compute Group Title
    Best Response
    You've already chosen the best response.
    Medals 2

    // Program For Question Number 5... #include<iostream.h> int main() { int ch; while(1) { cout<<"\n 1.Red\n 2.Red and Amber\n 3.Green\n 4.Amber\n 5.Exit\n"; cout<<"Enter ur choice\n"; cin>>ch; switch(ch) { case 1: cout<<"Red and Amber\n"; break; case 2: cout<<"Green\n"; break; case 3: cout<<"Amber\n"; break; case 4: cout<<"Red\n"; break; case 5: return(0); default:cout<<"Invalid Choice\n"; break; } } }

    • one year ago
  5. compute Group Title
    Best Response
    You've already chosen the best response.
    Medals 2

    @oldrin.bataku I m not familiar wid dis version of C++(Dev C++). I had written dat progrm only in C++ language...and I hope it will work in dat version also. and I think the things u had written about d syntax will work in linux os not in windows...

    • one year ago
  6. oldrin.bataku Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    @compute your code is that which is not standards-compliant and therefore not portable. By the way, C++ has a built-in bool type, so no need to use 1 in place of true. Aside from that, the OP asked for C code, not C++, and your solution for 5 doesn't work.

    • one year ago
  7. compute Group Title
    Best Response
    You've already chosen the best response.
    Medals 2

    @oldrin.bataku he had mentioned dat he is using some version of c++ so I had written those progm in c++...by d way where is problm in 5 becz its working in my systm...

    • one year ago
  8. oldrin.bataku Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    Nevermind, I misread question 5... but my point still stands. Remove from your mind this notion of "versions" of C++; concern yourself with what the standard guarantees, and maybe in some cases compiler-specific implementation-defined behavior or extensions.

    • one year ago
  9. JadeEyes Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    ..Thank you for your answers..!! @oldrin.bataku ...This is the program the lecturer told us to use. So that's why I'm using that one.

    • one year ago
  10. compute Group Title
    Best Response
    You've already chosen the best response.
    Medals 2

    @oldrin.bataku if u have a better solutin den why didn't u post here, it will be helpful 4r me also...

    • one year ago
  11. compute Group Title
    Best Response
    You've already chosen the best response.
    Medals 2

    @JadeEyes r these prgms wrkng in ur system????

    • one year ago
  12. JadeEyes Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    I'm checking it..!! :)

    • one year ago
  13. compute Group Title
    Best Response
    You've already chosen the best response.
    Medals 2

    k..

    • one year ago
  14. JadeEyes Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    They work..!! Thank you..!! :) ..!!

    • one year ago
  15. oldrin.bataku Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    #include <stdio.h> int main() { double mark; fputs("Mark: ", stdout); scanf("%lf", &mark); if (mark > 100 || mark < 0) { puts("The mark input is invalid"); } else if (mark >= 70) { puts("First Class Honours"); } else if (mark >= 60) { puts("Upper Second Class Honours"); } else if (mark >= 50) { puts("Lower Second Class Honours"); } else if (mark >= 40) { puts("Third Class Honours"); } else { puts("Not an honours degree"); } }

    • one year ago
  16. compute Group Title
    Best Response
    You've already chosen the best response.
    Medals 2

    @oldrin.bataku nice program but I think dere is some problm in ur logic becz 1) why u had written marks greater than 100 and less than 0??? 2) In if condition u use a symbol 4r 'or' means any one of d condition will true it will work...means if number is gearter than 100 or number is less than 0...???

    • one year ago
  17. oldrin.bataku Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    The code works fine and is in C using stdio.h like OP requested. The following code also works. #include <stdio.h> int main() { double mark; fputs("Mark: ", stdout); scanf("%lf", &mark); puts(mark > 100 || mark < 0 ? "The mark input is invalid" : mark >= 70 ? "First Class Honours" : mark >= 60 ? "Upper Second Class Honours" : mark >= 50 ? "Lower Second Class Honours" : mark >= 40 ? "Third Class Honours" : "Not an honours degree"); }

    • one year ago
    • Attachments:

See more questions >>>

Your question is ready. Sign up for free to start getting answers.

spraguer (Moderator)
5 → View Detailed Profile

is replying to Can someone tell me what button the professor is hitting...

23

  • Teamwork 19 Teammate
  • Problem Solving 19 Hero
  • You have blocked this person.
  • ✔ You're a fan Checking fan status...

Thanks for being so helpful in mathematics. If you are getting quality help, make sure you spread the word about OpenStudy.

This is the testimonial you wrote.
You haven't written a testimonial for Owlfred.