Im writing a program that will ask a user how many tests they have, read those tests, average them, and then display the average as a pass or a fail. IE A is a 80% or higher, using a seperate function to average the imput values. Errors are in the lrt string section. Can anyone see where Im going wrong? Thanks
#include <iostream>
#include <cmath>
#include <cassert>
#include <cctype>
#include <conio.h>
usingnamespace std;
double avg(double ttl, int z);
//Main function variables
int main()
{
int numberoftests;
double totaltestscore = 0.0;
//Purpose of the program
cout <<"Today you are finally able to imput all of your tests, " ;
cout << "and see if you are passing or failing." ;
cout <<"So How many test are we averaging buddy? " ;
//Getting the number of tests from the user
cin >> numberoftests;
//Looping to collect all the test scores
for (int i=0; i < numberoftests; i++)
{
//indtestscore is the users each individual test score
double indtestscore, average;
cout << "Imput your test score bitch.." ;
cin >> indtestscore;
//Adding this to the total
totaltestscore+=indtestscore;
}
double average;
average = avg(totaltestscore, numberoftests);
string ltr = "";
cout << "Looks like your average is a" << average << "." ;
if (average <= 49)
ltr = "F, you fail... Congrats";
if (average <= 59 && average >= 50)
ltr = "D";
if (average <= 69 && average >= 60)
ltr = "C";
if (average <= 79 && average >= 70)
lrt = "B";
if (average >= 80)
lrt = "A... Browner";
cout <<"Your grade is" << lrt;
}
//The function to calculate the average of the user
double avg(double ttl, int z);
{
double average;
average = ttl/z;
return average;
}
#include <iostream>
#include <cmath>
#include <cassert>
#include <string>
#include <cctype>
#include <conio.h>
usingnamespace std;
double avg(double ttl, int z);
//Main function variables
int main()
{
int numberoftests=0;
double totaltestscore = 0.0;
double indtestscore=0.0,average=0.0;
//Purpose of the program
cout <<"Today you are finally able to imput all of your tests, " ;
cout << "and see if you are passing or failing." ;
cout <<"So How many test are we averaging buddy? " ;
//Getting the number of tests from the user
cin >> numberoftests;
//Looping to collect all the test scores
for (int i=0; i < numberoftests; i++)
{
//indtestscore is the users each individual test score
cout<<"Imput your test score bitch.." ;//wow u better mind he language u use :P
cin>>indtestscore;
//Adding this to the total
totaltestscore+=indtestscore;
}
average = avg(totaltestscore, numberoftests);
std::string ltr=" ";
cout << "Looks like your average is a" << average << "." ;
if (average <= 49)
ltr = "F, you fail... Congrats";
if (average <= 59 && average >= 50)
ltr = "D";
if (average <= 69 && average >= 60)
ltr = "C";
if (average <= 79 && average >= 70)
ltr = "B";
if (average >= 80)
ltr = "A... Browner";
cout <<"Your grade is" << ltr;
}
//The function to calculate the average of the user
double avg(double ttl, int z)
{
double average;
average = ttl/z;
return average;
}