You need to try to decide whether or not you have enough money for rent this month. In order to make this decision you need the following information:
a) How many hours you work each week
b) Your hourly pay
c) Your grocery bill
d) Your utility bills
e) Your entertainment/other expenses
f) Rent
Assume there are four weeks during the month. Assume that overtime pay is 50% more than regular pay and that you get paid overtime for each hour over 40 that you work a week. Since groceries, utilities and entertainment take precendence over rent, you'll ONLY be able to pay the rent if the sum of the costs of c through f are less than or equal to the total money you make at your job.
Sample Run (User input in bold and italics)
How many hours do you work a week?
45
What is your hourly pay in dollars?
10.50
What is your grocery bill for the month?
200.00
What are your utility bills for the month?
150.50
What are your entertainment/other expenses for the month?
700.00
What is your rent for the month?
800.00
Great, you can pay your rent!
Note: If you can't pay your rent, print out, "Sorry, you can't pay your rent."
Computer science, programming c question?
#include%26lt;iostream%26gt;
int main(){
std::cout %26lt;%26lt; "How many hours do you work a week? \n";
double hoursWorked;
std::cin%26gt;%26gt;hoursWorked;
std::cout %26lt;%26lt; "What is your hourly pay?\n"
double pay;
std::cin%26gt;%26gt; pay;
std::cout %26lt;%26lt; "What is your grocery bill for the month? \n"
double groceryBill;
std::cin%26gt;%26gt; groceryBill;
std::cout %26lt;%26lt; "What are your utility bills for the month? \n";
double utilityBills;
std:: cin %26gt;%26gt; utilityBills;
std::cout %26lt;%26lt; "What are your misc. expenses for the month?\n";
double miscExp;
std::cin %26gt;%26gt; miscExp;
std::cout %26lt;%26lt; "What is your rent?\n";
double rent;
std::cin %26gt;%26gt; rent;
double totalExpenses = utilityBills + groceryBill + misExp;
double moneyEarned;
if(hoursWorked %26gt; 40){
moneyEarned = 40 * pay + ((hoursWorked - 40)*pay * 1.5);
}else{
moneyEarned = hoursWorked * pay;
};
if(moneyEarned-totalExpenses %26gt;= rent)
std::cout %26lt;%26lt; "Great you can pay your rent";
else
std::cout %26lt;%26lt; "You can't pay your rent";
return 0;
};
that will compile on G++, there are prolly some spelling errors i didnt try and compile it but it should work
Reply:the above program works with almost every compiler
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment