I'm super stressed out, nothing comes to my mind, I'm trying to refresh doing some simple programs and I can't do them, yesterday I spent like 2 h trying to do this...:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
|
#include <iostream>
using namespace std;
int main()
{
int i=0, months = 36;
double fee = 0.03, price=0.0;
double montly_fee = 1000.0;
cout << "Welcome to my appartment complex"<<endl;
cout << "The price of the app. per month is $1000 and I'll increment 3% of interest for 3 years." <<"\n\n";
for (i = 1; i <= 3; i++)
{
double compute=0.0, get_money=0.0, total=0.0, x=0.0;
compute = (montly_fee*fee); //Gives me $30
get_money = (12 * (compute + montly_fee)); //Calculates a whole year, gives me $12360
total=get_money*i;
cout << "Year (" << i << ") $" << total << endl; //Displays total
}
cin.ignore();
cin.get();
return 0;
}
| |
So now, I'm trying to do another simple program but nothing comes to my mind, I have 1 week left and the trigonometry final and the c++ final! ahhhg
so I'm trying to do this:
Calculate the purchase of video game sales.
If customer buys more than 3 games, the forth one is free.
Ask how many the user is purchasing.
Ask whether the game is a new release or not.
Then display the total of the purchase
but I can't pass the values to the one another. I know it's a lot to ask, but could you do it please?
I tryied to do it simple, without functions, because back then we didn't see functions, but I ended up including some. Can you please do it? So I can analize it. This is what I have:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102
|
#include <iostream>
using namespace std;
//Prototypes
void show_menu();
int option1(int);
//Globals
//int user_option=0;
const double new_games = 9.95, other_games = 7.95;
int main()
{
/*
Calculate the purchase of video game sales.
If customer buys more than 3 games, the forth one is free.
Ask how many the user is purchasing.
Ask whether the game is a new release or not.
Then display the total of the purchase
*/
show_menu();
cout << "Ok.. bye bye!";
cin.ignore();
cin.get();
return 0;
}
void show_menu()
{
cout << "Hi, welcome to GameStop, follow the menu to buy new/used games.\n\n";
cout << R"(
-------------------------------------
|Option 1- Buy new games/New release|
|Option 2- Buy used games |
|Option 3- Exit/Finish buying |
-------------------------------------
)";
}
int option1(int x)
{
int buy_new = 0, total = 0, user = 0;
if (user == 1)
{
cout << "\nHow many new games would you like to buy? ";
cin >> buy_new;
if (buy_new >= 3)
{
cout << "\nYou have a discount! You have 1 free game.\n";
cout << "You're buying " << buy_new << " games + 1 free.";
total = buy_new + 1;
}
}
return total;
}
void loop()
{
int user = 0, option1_total=0;
cout << "\t\t\tEnter an option: ";
cin >> user;
while (user > 0 && user < 3)
{
option1_total=
cout << "\t\t\tAnything else?: ";
cin >> user;
}
cout << "\nWould you like to buy something else? ";
cin >> user;
}
}
| |