My lab instructor is trying to switch to automated grading and didn't tell anyone. Now, the program that works in every other compiler I've tried gets (infinite loop) in zybooks even when I use an identical input file. I have no clue what the problem is, also yes I know the writing is super scuffed, there's a constrictive set of instructions that makes me code like this ;-; Also i know the cin.ignore is incomplete, im working on it but would like to be able to compile in zybooks so that i know i can submit my assignment before doing that.
Here's my input:
Apples
1
2
y
Beets
2
3
#include <iostream>
using namespace std;
#include "ItemToPurchase.h"
int main() {
int itemCount = 2;
string tempName;
int tempPrice;
int tempQuantity;
char yesNo;
itemToPurchase item1, item2;
printf("Item 1\n\nItem Name:\n");
cin >> tempName;
item1.setName(tempName);
printf("Enter the items price: \n");
cin >> tempPrice;
item1.setPrice(tempPrice);
printf("Enter the item quantity: \n");
cin >> tempQuantity;
item1.setQuantity(tempQuantity);
printf("\nAre you sure? (Y or N)\n");
cin >> yesNo;
if(yesNo == 'Y' || yesNo == 'y')
{
}
if(yesNo == 'N' || yesNo == 'n')
{
cin.ignore(6,'\n');
}
printf("\nItem 2\n\nItem Name:\n");
cin >> tempName;
item2.setName(tempName);
printf("Enter the items price: \n");
cin >> tempPrice;
item2.setPrice(tempPrice);
printf("Enter the item quantity: \n");
cin >> tempQuantity;
item2.setQuantity(tempQuantity);
int total1;
int total2;
int sumTotal;
total1 = item1.getPrice() * item1.getQuantity();
total2 = item2.getPrice() * item2.getQuantity();
sumTotal = total1+total2;
cout << endl << "TOTAL COST" << endl << item1.getName() << " " <<
item1.getQuantity() << " * " << item1.getPrice() << " = " << total1 << endl << item2.getName() << " " << item2.getQuantity() << " * " << item2.getPrice() << " = " << total2 << endl << "TOTAL COST = $" << sumTotal << endl;
return 0;
}