34. Write a program that keeps track the Lemonade sales for five weekdays: Monda
ID: 3659588 • Letter: 3
Question
34. Write a program that keeps track the Lemonade sales for five weekdays: Monday, Tuesday, Wednesday, Thursday, and Friday. It should use two parallel five-element arrays: an array of strings that holds the five weekdays and an array of double that holds the sales amount for each day. The weekday names should be stored using an initialization list at the time the name array is created. The program should prompt the user to enter the sales amount sold for each day. Once the sales data has been entered, the program should produce a report that displays sales for each day and total sales for five days. Input Validation: Do not accept negative numbers for daily sales amount.Explanation / Answer
#include <iostream>
using namespace std;
int main()
{
string weekDays[]={"Monday","Tuesday","Wednesday","Thursday","Friday"};
int sales[5];
int temp,i,sum=0;
cout<<" Enter the sales for a week.";
for(i=0;i<5;i++)
{
do
{
cout<<" Sales for "<<weekDays[i]<<" :";
cin>>temp;
if(temp<0)
{
cout<<"Invalid sales. Please Reenter:";
}
}while(temp<0);
sales[i]=temp;
}
cout<<" Sales for a week :";
for(i=0;i<5;i++)
{
cout<<" "<<weekDays[i]<<" :"<<sales[i];
sum=sum+sales[i];
}
cout<<" Total Sales :"<<sum;
return 0;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.