IF / ELSE IF Problem

I can't figure out how to correctly format this code to make the program work, been at it for days now. Still learning. Could someone show and explain please? The IF / ELSE IF problem is towards the bottom.

#include <iostream>
#include <iomanip>
using namespace std;

int main()
{
//Variables
int EntertainAmt;
int FoodAmt;
int OtherAmt;
int points;
int EntertainPoints;
int FoodPoints;
int OtherPoints;
int pizzas;
int movieRentals;
int itunes;
int leftovers;
int P;
int M;
int I;
char Rewards;

cout << "Adventure Rewards Program" << endl;

//Inputs
cout << "Enter dollar amount of your Entertainment purchases: $";
cin >> EntertainAmt;
cout << "Enter dollar amount of your Food purchases: $";
cin >> FoodAmt;
cout << "Enter dollar amount of any other purchases: $";
cin >> OtherAmt;
cout << endl;

//Calculations for first part
EntertainPoints = EntertainAmt * 5;
FoodPoints = FoodAmt * 2;
OtherPoints = OtherAmt * 1;
points = EntertainPoints + FoodPoints + OtherPoints;

//Output of points earned
cout << "Total number of points earned: " << points;

//Calculations for last part
M = movieRentals;
P = pizzas;
I = itunes;
leftovers = P - M - I;
Rewards = P, M, I;

//Final input that determines how points are distributed
cout << "Enter your choice for rewards- (M)ovies, (P)izzas or (I)tunes: ";
cin >> Rewards;

if (M == points / 150)
{
else if (P == points / 300)
}
{
else if (I == points / 60)
}

if (P == points / 300)
{
else if (M == points / 150)
}
{
else if (I == points / 60)
}

if (I == points / 60)
{
else if (P == points / 300)
}
{
else if (M == points / 150)
}

//Output of points into rewards
cout << "You have earned the following rewards for your credit card purchase!" << endl;
cout << P << "Pizzas (300 points each)" << endl;
cout << M << "Movie Rentals (150 points each)" << endl;
cout << I << "iTunes downloads (60 points each)" << endl;
cout << leftovers << "points leftover" << endl;


system("pause");
return 0;
}
1
2
3
M = movieRentals;
P = pizzas;
I = itunes;

movieRentals, pizzas, itunes are all uninitialized variables. You're storing garbage into M,P and I.

Not sure what you're trying to do with your if/else statements. You have no actions within any of the statement blocks.

 
Rewards = P, M, I;

Do you understand what the comma operator does? That statement is useless as you overlay Rewards a few lines later.

What's the point of asking for Rewards? You don;t use the variable once you've asked for it.

PLEASE USE CODE TAGS (the <> formatting button) when posting code.
It makes it easier to read your code and also easier to respond to your post.
http://www.cplusplus.com/articles/jEywvCM9/
Hint: You can edit your post, highlight your code and press the <> formatting button.
Last edited on
Topic archived. No new replies allowed.