// Budget Calculating Program
// By GB
// This program will determine if the user has gone over his budget
// by taking the values provided and doing simple arithmetic calculations
// and if/else statements.
#include <iostream> // Required for cout and endl
#include <cmath> // Required for sqrt()
usingnamespace std;
int main()
{
// Declare variables.
double sausagepc(5), beerpc(17), total,
sausage, beer, budget;
cout<<"The following program will help you stay within your party budget."
<< "Enter the number of sausages: /n";
cin >> sausage;
cout << "Enter the number of beer buckets: /n";
cin >> beer;
cout << "Enter budget: /n";
cin >> budget;
// Computation
total = sausagepc*sausage + beerpc*beer;
// If/Else statement
If (total>budget)
{
cout << "You have gone over your budget!";
}
Else
{
cout << "You are within your budget.";
endl;}
return 0;
}
1) C++ is case sensitive. "if" and "else" should be lowercase.
2) Line 34 should be cout << "You are within your budget." << endl;}
3) it's "\n", not "/n"