Alright, I need a program that has both a selection structure and a repetition structure. Would someone please tell me if I am doing this right. My code gives me the correct output but do I have a selection and repetition structure?
#include <iostream>
using namespace std;
int main ()
{
// variables
double incomes = 0.0;
double spending = 0.0;
int totalIncome = 0;
int totalSpending = 0;
int subTotal = 0;
int grandTotal = 0;
int counterIncome = 1;
int counterSpending = 1;
while (incomes >= 0)
{
totalIncome += incomes;
cout << "Enter week " << counterIncome << " income value (negative value to stop): ";
cin >> incomes;
counterIncome += 1;
}
while (spending >= 0)
{
totalSpending += spending;
cout << "Enter week " << counterSpending << " spending value (negative value to stop): ";
cin >> spending;
counterSpending += 1;
}
counterIncome += 1;
grandTotal = totalIncome - totalSpending;
//diaplay subtotal and grandtotal
cout << "Subtotal Income is: $ " << totalIncome << endl;
cout << "Grand Total Profit is: $ " << grandTotal << endl;
return 0;
}