Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Grades

Grades

Scheduled Pinned Locked Moved C / C++ / MFC
businesslearning
5 Posts 3 Posters 11 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Stephanie Foley
    wrote on last edited by
    #1

    Use an input file An instructor has asked you to write a program that can tell him if his students have passed or failed his course. He has a file that contains the following information: • first name • last name • five quiz grades • the midterm exam grade • the final exam grade Your program must read these values into variables then use those variables to calculate the final average and finally display that average to the screen. Requirements: 1. All input comes from a file – grades.txt. You may NOT ask for input from the professor. This file is posted on Canvas for your program to use. 2. Remember: Your program must calculate the final average including those quizzes. All the quizzes averaged together count as much as a test. So, to calculate the final, you need to calculate the quiz average first, then average the midterm + final + quiz average. 3. Display the student’s last name first, comma, space and first name. Follow that with the final average as a whole number, rounded up The file contains one line of data in the following order: firstName lastName q1 q2 q3 q4 q5 midterm final Remember, data must be read in sequentially! This means that the first name variable must be initialized before the last name or the quiz one and etc. Code: #include #include using namespace std; /* run this prgram using the console pauser or add your own getch, system('pause") or input look */ int main(int argc, char** argv) { string firstName,lastName; int q1, q2, q3, q4, q5, midterm, final; int quizaverage; int average; ifstream inFile; inFile.open("grades.txt"); inFile>>firstName>>lastName>>q1>>q2>>q3>>q4>>q5>>midterm>>final; //Calculate the quiz average. quizaverage=(q1+q2+q3+q4+q5)/5; average=(quizaverage+midterm+final)/3*100; cout<<"Dobbs, Bob"<<" Average: "<

    L 1 Reply Last reply
    0
    • S Stephanie Foley

      Use an input file An instructor has asked you to write a program that can tell him if his students have passed or failed his course. He has a file that contains the following information: • first name • last name • five quiz grades • the midterm exam grade • the final exam grade Your program must read these values into variables then use those variables to calculate the final average and finally display that average to the screen. Requirements: 1. All input comes from a file – grades.txt. You may NOT ask for input from the professor. This file is posted on Canvas for your program to use. 2. Remember: Your program must calculate the final average including those quizzes. All the quizzes averaged together count as much as a test. So, to calculate the final, you need to calculate the quiz average first, then average the midterm + final + quiz average. 3. Display the student’s last name first, comma, space and first name. Follow that with the final average as a whole number, rounded up The file contains one line of data in the following order: firstName lastName q1 q2 q3 q4 q5 midterm final Remember, data must be read in sequentially! This means that the first name variable must be initialized before the last name or the quiz one and etc. Code: #include #include using namespace std; /* run this prgram using the console pauser or add your own getch, system('pause") or input look */ int main(int argc, char** argv) { string firstName,lastName; int q1, q2, q3, q4, q5, midterm, final; int quizaverage; int average; ifstream inFile; inFile.open("grades.txt"); inFile>>firstName>>lastName>>q1>>q2>>q3>>q4>>q5>>midterm>>final; //Calculate the quiz average. quizaverage=(q1+q2+q3+q4+q5)/5; average=(quizaverage+midterm+final)/3*100; cout<<"Dobbs, Bob"<<" Average: "<

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      Stephanie Foley wrote:

      I need help with this

      Exactly what help do you need?

      S 1 Reply Last reply
      0
      • L Lost User

        Stephanie Foley wrote:

        I need help with this

        Exactly what help do you need?

        S Offline
        S Offline
        Stephanie Foley
        wrote on last edited by
        #3

        I need to use an input file to find that course average. The course average is a mathematical expression involved in quiz average, midterm grade, and final grade. I am trying to get the program to read what is in the file. There is the first name, last name, and 7 numbers. I need to use these values in the program to get an average for the class.

        L J 2 Replies Last reply
        0
        • S Stephanie Foley

          I need to use an input file to find that course average. The course average is a mathematical expression involved in quiz average, midterm grade, and final grade. I am trying to get the program to read what is in the file. There is the first name, last name, and 7 numbers. I need to use these values in the program to get an average for the class.

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #4

          Well you stated that in your original question. But you have still not explained what your problem is.

          1 Reply Last reply
          0
          • S Stephanie Foley

            I need to use an input file to find that course average. The course average is a mathematical expression involved in quiz average, midterm grade, and final grade. I am trying to get the program to read what is in the file. There is the first name, last name, and 7 numbers. I need to use these values in the program to get an average for the class.

            J Offline
            J Offline
            jeron1
            wrote on last edited by
            #5

            How are your results different from what is expected? Also, showing the files exact contents would be helpful.

            "the debugger doesn't tell me anything because this code compiles just fine" - random QA comment "Facebook is where you tell lies to your friends. Twitter is where you tell the truth to strangers." - chriselst "I don't drink any more... then again, I don't drink any less." - Mike Mullikins uncle

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups