I have a program where you imput a grade from 0% to 100% and it will output your letter grade. Im getting an error saying cout is ambiguous. Any help would be appreciated!
#include <iostream>
#include <cmath>
#include <cassert>
#include <cctype>
#include <conio.h>
#include <string>
usingnamespace std;
//Main function variables
int main()
{
double average;
//Purpose of the program
cout <<"\nPlease Imput your test score " ;
//Getting the number of tests from the user
cin >> 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 << "\nYour letter grade is... " <<ltr;
getch();
}
int main()
{
double average;
//Purpose of the program
cout <<"\nPlease Imput your test score " ;
//Getting the number of tests from the user
cin >> average;
}
That's your complete main function. See this bit straight after it:
1 2 3 4 5 6 7 8 9 10 11 12 13 14
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 << "\nYour letter grade is... " <<ltr;
getch();
}
That's not in any function and it's got a closing } at the end, but there's no opening { that seems to go with it.
There's no definition of ltr
#include <iostream>
#include <cmath>
#include <cassert>
#include <cctype>
#include <conio.h>
#include <string>
usingnamespace std;
//Main function variables
int main()
{
double average;
//Purpose of the program
cout <<"\nPlease Imput your test score " ;
//Getting the number of tests from the user
cin >> average;
{
{
cout << "bitch" ;
double average;
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 << "\nYour letter grade is... " <<ltr;
getch();
}
}
Still not running but I have no errors as I write the program, saying there's an error on #include <iostream>