Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a program that keeps track the Lemonade sales for five weekdays: Monday, T

ID: 3569383 • Letter: W

Question

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<stdio.h>
#include <string.h>
#include <stdlib.h>


int main()
{
char *day[5]={"mon","tue","wed","thu","fri"};
int a2[5];

printf(" Enter the amount on Monday ");
scanf("%d", &a2[0]);

printf(" Enter the amount on Tuesday ");
scanf("%d", &a2[1]);

printf(" Enter the amount on Wednesday ");
scanf("%d", &a2[2]);

printf(" Enter the amount on Thursday ");
scanf("%d", &a2[3]);

printf(" Enter the amount on Friday ");
scanf("%d", &a2[4]);

int i;
for(i=0; i<5; i++)
{
if(a2[i]<0)
a2[i]=0;
}
for(i=0; i<5; i++)
{
printf(" The Amount on %s day is ", day[i]);
printf("%d ", a2[i]);
}
return 0;
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote