| | |
percentage
Please support our C++ advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Nov 2004
Posts: 3
Reputation:
Solved Threads: 0
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;
}
//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;
}
•
•
Join Date: Nov 2004
Posts: 3
Reputation:
Solved Threads: 0
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;
}
#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;
}
![]() |
Similar Threads
- Image Comparison Application using ASP.net?..Result in Percentage Format?..!! (ASP.NET)
- Formula for percentage? (Visual Basic 4 / 5 / 6)
- word counter, frequency, percentage (Java)
- Keyword Search and return match percentage (ASP)
- How to get the percentage..?? (MySQL)
- Format Number as percentage. (PHP)
Other Threads in the C++ Forum
- Previous Thread: I keep getting an error message on my computer called General Protection Exception...
- Next Thread: No idea how to do this problem...
Views: 3271 | Replies: 4
| Thread Tools | Search this Thread |
Tag cloud for C++
6 api application array arrays based beginner binary c++ c/c++ calculator char char* class classes code coding compile compiler console conversion convert count data database delete developer display dll dynamiccharacterarray email encryption error file format forms fstream function functions game generator givemetehcodez graph iamthwee ifstream image input int java lib list loop looping loops map math matrix memory multiple newbie news number numbertoword output pointer problem program programming project python random read recursion recursive reference return rpg search simple sort sorting spoonfeeding string strings struct template templates text tree url variable vector video visual visualstudio win32 windows winsock wordfrequency wxwidgets






