Console & Computer Gaming Latest news in the world of gaming. Xbox One, PS4, and more…

Any C/C++ Programmers help me out??

Thread Tools
 
Old 02-07-2006, 07:21 PM
  #1  
5th Gear
Thread Starter
 
Lifter2012's Avatar
 
Join Date: Apr 2004
Location: FL
Age: 39
Posts: 5
Likes: 0
Received 0 Likes on 0 Posts
Any C/C++ Programmers help me out??

Hey guys, can any C/C++ programmers help me out with this program i'm trying to work on for class? I dont have it all done yet and i knwo some of its not exactly on track.

Project:
Write a program that predicts the score needed on a final exam to achieve a desired grade in a course. The program should interact with the user as shown in the sample output below.
For those who get nervous about calculating the numbers the following formulas will help:
(1 – percent final counts)* current GPA = points earned
(min avg for grade – points earned) / percent final counts = grade needed on exam
There are other ways to get the correct answers if you prefer to use different calculations.

Sample Output:
Enter desired grade: A
Enter minimum average for this grade: 89.60
Enter current grade point average: 86.90
Enter percent the final exam counts(in decimal form): 0.30
You will need a 95.90 on the final exam.







What I have so Far:


//* Mark K Assignment 1 February 8 2006*//

#include <stdio.h>

int main()
{ //declarevariables
char letter = 'a'; double avg = 89.60; double grd avg = 86.90; double
final = 0.30;

printf ("The desired grade is %c",a);
scanf (" %c", &a);

printf ("Minimum average is %f", 89.60);
scanf (" %lf", &avg);

return 0;
}




This is the format it is supposed to be:
int main( )
{
Variable declarations go here.

This is where you should get your user information. You should have one prompt (printf statement) for every piece of information you are expecting the user to enter. This should be paired with a statement that accepts data from the keyboard (scanf statement).

This is where you perform your calculations.

This is where you display the results of your calculation.

return 0;
}
Old 02-08-2006, 01:46 PM
  #2  
Safety Car
 
WdnUlik2no's Avatar
 
Join Date: Jun 2005
Location: Atlanta
Age: 47
Posts: 4,566
Received 34 Likes on 16 Posts
Based on what you said, the final grade letter is not really needed if you are going to give the program that minimal grade average anyway. You can however have the program determine the minimal number grade automatically based on what letter you type in so you won't even need to ask for the "minimal average". I will let you figure that out yourself, but to answer your main question try this:

(I haven't worked with C++ in a long time so I may have some syntax errors, but I wrote the code based on your information and formulas you provided. I have not checked your formulas for accuracy.

#include<iostream.h>

float minGrade; //desired GPA
float currentGrade, // current GPA
float finalWeight; // for exam percentage.
char desiredGrade; //Letter grade

void main()
{
cout << "Enter desired grade " << endl;
cin >> desiredGrade; //Not really needed, unless you will use this to determine the "minimum average for that grade"

cout << "Enter minimum average for this grade: " << endl;
cin >> minGrade;

cout << "Enter current grade point average: " << endl;
cin >> currentGrade;

cout << "Enter percent the final exam counts(in decimal form): 0.30" << endl;
cin >> finalWeight;

cout << "You will need a " << calculateGrade(minGrade, currentGrade, finalWeight) << " on the final exam." << endl; //the fuction calculateGrade is defined as a float, so you can treat it as such in this statement.
}

//This fuction calculates the minimal grade needed to achieve the desired grade. It passes in minGrade, currentGrade and finalWeight from main.

float calculateGrade(float DESIRED, float CURRENT, float PERCENT);
{
float pointsEarned;
pointsEarned = PERCENT * CURRENT;
return (DESIRED - pointsEarned)/PERCENT;
}
Old 02-08-2006, 03:13 PM
  #3  
Safety Car
 
WdnUlik2no's Avatar
 
Join Date: Jun 2005
Location: Atlanta
Age: 47
Posts: 4,566
Received 34 Likes on 16 Posts
I see an error in my code, no semicolon should be on the end of the function calculateGrade.

float calculateGrade(float DESIRED, float CURRENT, float PERCENT);
{
float pointsEarned;
pointsEarned = PERCENT * CURRENT;
return (DESIRED - pointsEarned)/PERCENT;
}
Related Topics
Thread
Thread Starter
Forum
Replies
Last Post
Yumcha
Automotive News
70
12-07-2020 05:39 PM
bradgottaTL_88
4G TL Performance Parts & Modifications
3
09-25-2015 01:04 PM



Quick Reply: Any C/C++ Programmers help me out??



All times are GMT -5. The time now is 04:22 PM.