percentage

Reply

Join Date: Nov 2004
Posts: 3
Reputation: old lady is an unknown quantity at this point 
Solved Threads: 0
old lady old lady is offline Offline
Newbie Poster

percentage

 
0
  #1
Nov 14th, 2004
I've written programs for averaging lists of exam grades but throwing in the percent is throwing me for a loop. I don't know how to handle this information. Any help will be greatly appreciated.


//Write a program that asks the user to enter a student's midterm
//and final exam scores. The program should display the midterm and
//final exam scores and the student's final grade. Compute the final
//grade by taking the sum of 40% of the midterm exam score and 60% of
//the final exam score.

#include <iostream.h>
#include<iomanip.h>

//using namespace std;

int main()
{
int. midterm,midterm;
final;final;
double 40% mid;
60% final;

cout<< set precision()
<<setiosflags(.40);
<<setiosflags(.60);

//obtain input data
cout<<"\nEnter midterm";
cin>>midterm exam;
cout<<"\nEnter final";
cin>>;final exam;

//Do the calculations
final grade = double (midterm + final);
cout<<"\n;????

return 0;
}
Reply With Quote Quick reply to this message  
Join Date: Sep 2004
Posts: 56
Reputation: jasweb2002 is an unknown quantity at this point 
Solved Threads: 2
jasweb2002 jasweb2002 is offline Offline
Junior Poster in Training

Re: percentage

 
0
  #2
Nov 14th, 2004
Is it compiling? I am not 100% confident with c++ but I don't think what your doing is possible. Try something like this...

final_grade = (.4*midterm)+(.6*final);
Reply With Quote Quick reply to this message  
Join Date: Nov 2004
Posts: 3
Reputation: old lady is an unknown quantity at this point 
Solved Threads: 0
old lady old lady is offline Offline
Newbie Poster

Re: percentage

 
0
  #3
Nov 16th, 2004
Thank you. It is surprising how one little thing like a percentage can totally destroy my brain. I haven't compiled this yet but I think it might work.

#include <iostream.h>
using namespace std;
int main()
{
float midterm, final, average;
cout<<"Enter a midterm grade:";
cin>>midterm;
cout<<"Enter a final grade:";
cin>>final;
average=(.4f*midterm)+(.6f*final);
cout<<"the average is:"<<average<<'\n';
return 0;
}
Reply With Quote Quick reply to this message  
Join Date: Sep 2004
Posts: 56
Reputation: jasweb2002 is an unknown quantity at this point 
Solved Threads: 2
jasweb2002 jasweb2002 is offline Offline
Junior Poster in Training

Re: percentage

 
0
  #4
Nov 16th, 2004
average=(.4f*midterm)+(.6f*final);

What are the f's for?
Reply With Quote Quick reply to this message  
Join Date: Nov 2004
Posts: 6,145
Reputation: jwenting is just really nice jwenting is just really nice jwenting is just really nice jwenting is just really nice 
Solved Threads: 212
Team Colleague
jwenting's Avatar
jwenting jwenting is offline Offline
duckman

Re: percentage

 
0
  #5
Nov 16th, 2004
In Java you would write .4f to force the floating point literal into a float instead of a double datatype.
Don't think C++ works like that.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC