Question

I have this code and need this to be written and applied with an array? How...

I have this code and need this to be written and applied with an array? How do I process this? Also What would I apply this with flowchart?

  1. Module main()

  2.   Call getDailyProfit()

  3.   Call calculateWeeklyProfit()

  4. Call main()

  5. Module getDailyProfit()

  6.   // Declare all variables and establish the array

  7.          Constant Real SIZE = 7

  8.          Declare String days[SIZE] = Sunday, Monday, Tuesday, Thursday. Friday, Saturday

  9.          Declare Real days

  10.          Declare Real number

  11.          Declare Real Index

  12.          

  13.   //Prompt the user for profit information for Sunday

  14.          Display “How much did the store profit on Sunday? ”

  15.          Input profitSunday

  16.     While profitMonday < 0

  17.          Display “Your profit cannot be negative. “

  18.          Display “Please enter your profit again. “

  19.          Input profitSunday

  20.     End While

  21.   //Call module profitMonday

  22.   Call profitMonday()

  23. End Module

  24. Module profitMonday()    

  25.   //Prompt the user for profit information for Monday

  26.          Display “How much did the store profit on Monday”

  27.          Input profitMonday

  28.     While profitMonday < 0

  29.          Display “Your profit cannot be negative. “

  30.          Display “Please enter your profit again. “

  31.          Input profitMonday

  32.     End While

  33.   //Call module profitTuesday

  34.   Call profitTuesday()

  35. End Module

  36.     

  37. Module profitTuesday

  38.   //Prompt the user for profit information for Tuesday

  39.          Display “How much did the store profit on Tuesday”

  40.          Input profitTuesday

  41.      While profitMonday < 0

  42.          Display “Your profit cannot be negative. “

  43.          Display “Please enter your profit again. “

  44.          Input profitTuesday

  45.     End While

  46.   //Call module profitWednesday

  47.   Call profitWednesday()

  48. End Module

  49. Module profitWednesday()    

  50.   //Prompt the user for profit information for Wednesday

  51.          Display “How much did the store profit on Wednesday”

  52.          Input profitWednesday

  53.     While profitMonday < 0

  54.          Display “Your profit cannot be negative. “

  55.          Display “Please enter your profit again. “

  56.          Input profitWednesday

  57.     End While

  58.   //Call module profitThursday

  59.   Call profitThursday()

  60. End Module

  61. Module profitThursday()     

  62.   //Prompt the user for profit information for Thursday

  63.          Display “How much did the store profit on Thursday”

  64.          Input profitThursday

  65.     While profitMonday < 0

  66.          Display “Your profit cannot be negative. “

  67.          Display “Please enter your profit again. “

  68.          Input profitThursday

  69.     End While

  70.   //Call module profitFriday

  71.   Call profitFriday()

  72. End Module

  73. Module profitFriday()

  74.   //Prompt the user for profit information for Friday

  75.          Display “How much did the store profit on Friday”

  76.          Input profitFriday     

  77.     While profitMonday < 0

  78.          Display “Your profit cannot be negative. “

  79.          Display “Please enter your profit again. “

  80.          Input profitFriday

  81.     End While

  82.   //Call module profitSaturday

  83.   Call profitSaturday()

  84. End Module

  85.     

  86. Module profitSaturday

  87.   //Prompt the user for profit information for Saturday

  88.          Display “How much did the store profit on Saturday”

  89.          Input profitSaturday

  90.     While profitMonday < 0

  91.          Display “Your profit cannot be negative. “

  92.          Display “Please enter your profit again. “

  93.          Input profitSaturday

  94.     End While

  95. End Module

  96. Module calculateWeeklyProfit

  97.   //Process all input to provide a weekly profit

  98.     Set weeklyProfit = profitSunday + profitMonday + profitTuesday + profitWednesday + profitThursday + profitFriday + profitSaturday

  99.   //Display the weeks profit after processing

  100.          Display “This week's current profit is $“, weeklyProfit

  101.   //If weekly profit exceeds $3500 then display that they have met their goal for the week

  102.   If weeklyProfit > 3500 then

  103.               Display “You have met your weekly goal! “

  104.   Else

  105.          Display “You have not met your weekly goal. “

  106. End Module

0 0
Add a comment Improve this question Transcribed image text
Answer #1

//above code with array implementation in C programming

#include<stdio.h>
#include<conio.h>
#define size 7
void getprofit()
{
   int days[size];
   int i=0,sum=0;
   for(i=0;i<7;i++)
   {
       if(i==0)
       {
           printf("Enter monday profit");
           scanf("%d",&days[i]);
           if(days[i]<0)
           {
               printf("profit can't be negative");
               printf("\nEnter monday profit");
               scanf("%d",&days[i]);
           }

       }
       if(i==1)
       {
           printf("Enter tuesday profit");
           scanf("%d",&days[i]);
           if(days[i]<0)
           {
               printf("profit can't be negative");
               printf("\nEnter tuesday profit");
               scanf("%d",&days[i]);
           }

       }
       if(i==2)
       {
           printf("Enter wednesday profit");
           scanf("%d",&days[i]);
           if(days[i]<0)
           {
               printf("profit can't be negative");
               printf("\nEnter wednesday profit");
               scanf("%d",&days[i]);
           }

       }
       if(i==3)
       {
           printf("Enter thursday profit");
           scanf("%d",&days[i]);
           if(days[i]<0)
           {
               printf("profit can't be negative");
               printf("\nEnter thursday profit");
               scanf("%d",&days[i]);
           }

       }
       if(i==4)
       {
           printf("Enter friday profit");
           scanf("%d",&days[i]);
           if(days[i]<0)
           {
               printf("profit can't be negative");
               printf("\nEnter friday profit");
               scanf("%d",&days[i]);
           }

       }
       if(i==5)
       {
           printf("Enter saturday profit");
           scanf("%d",&days[i]);
           if(days[i]<0)
           {
               printf("profit can't be negative");
               printf("\nEnter saturday profit");
               scanf("%d",&days[i]);
           }

       }
       if(i==6)
       {
           printf("Enter sunday profit");
           scanf("%d",&days[i]);
           if(days[i]<0)
           {
               printf("profit can't be negative");
               printf("\nEnter sunday profit");
               scanf("%d",&days[i]);
           }

       }
   }
   for(i=0;i<7;i++)
   {
       sum=sum+days[i];
   }
   printf("this week's current profit is %d",sum);
   if(sum>3500)
       printf("\nYou have met your weekly goal...!");
   else
       printf("\nYou have not met your weekly goal");
}
void main()
{
   clrscr();
   getprofit();
   getch();
}

Add a comment
Know the answer?
Add Answer to:
I have this code and need this to be written and applied with an array? How...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • I have this code and need this to be written and applied with an array? How do I process this? Also What would I apply t...

    I have this code and need this to be written and applied with an array? How do I process this? Also What would I apply this with flowchart? Module main()   Call getDailyProfit()   Call calculateWeeklyProfit() Call main() Module getDailyProfit()   // Declare all variables and establish the array          Constant Real SIZE = 7          Declare String days[SIZE] = Sunday, Monday, Tuesday, Thursday. Friday, Saturday          Declare Real days          Declare Real number          Declare Real Index             //Prompt the user for profit information for Sunday          Display “How...

  • I need to write a program in java using two array lists. I need to program...

    I need to write a program in java using two array lists. I need to program to prompt the user to enter a day of the week and return an output of a predetermined temperature for the day they selected. I also need the program the output the average of daily temperatures across the week if the user inputs "week". So basically if i set the temperatures to something arbitrary i.e.: Monday = 50 Tuesday = 55 Wednesday = 52...

  • Write the pseudocode below as a working Python program. Take a screenshot of your code and...

    Write the pseudocode below as a working Python program. Take a screenshot of your code and output and paste into your answer document. User input of ‘y’ or ‘Y’ should cause the loop to continue.    // Constant for the commission rate    // Declare as a global variable    Constant Real COMMISSION_RATE = 0.10     Module main()        // Local variable         Declare String keepGoing = "y"         // Calculate as many commissions         // as needed.         While...

  • Need this program ASAP C++ language 1b. Write the implementation file timeClock.cpp for the class TimeClock....

    Need this program ASAP C++ language 1b. Write the implementation file timeClock.cpp for the class TimeClock. Com pile the file, and save it in the Chap 13 folder of your Student Data Files. 1c. Write a C++ program named weeklyPay.cpp to test your class Timeclock Your program should ask the user how many hours the user worked each day of the week. An object should be created for each day of the week with the number of hours for each...

  • Write a C++ program using four enumerators. Initialize each as follows: 1. first, second, third, fourth,...

    Write a C++ program using four enumerators. Initialize each as follows: 1. first, second, third, fourth, fifth, sixth, seventh, eighth, ninth 2. Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday 3. curve, fast, knuckle, slider 4. single, double, triple, homer The program should prompt a user to input a character array or 4 numbers pertaining to each enumerator. Display help text to assists the user. The help text should display the smallest and largest possible valuesfor each inputted number. Validate the...

  • 1) Write a MATLAB script to prompt a user to input two numbers, then assess whether...

    1) Write a MATLAB script to prompt a user to input two numbers, then assess whether the two numbers are equal or not. If the two numbers are equal, display that they are equal in the Command Window. If they are not equal, display that they are not equal in the Command Window. 2) Write a MATLAB script that prompts the user to enter the day of the week using the input function. If the information the user enters is...

  • JAVA Project Please have the code written in JAVA This is a game I am trying...

    JAVA Project Please have the code written in JAVA This is a game I am trying to develop. Please let me know if its possible and what the base code is. Prompt User “Hello! Welcome to the game.” Prompt User “To begin the game, please enter a letter” Random word generator, will set the String to a new word After the user inputs a letter, the computer will enter a loop Once in the loop the computer will test each...

  • Pseudocode please Special Problem for Swap A local zoo wants to keep track of how many...

    Pseudocode please Special Problem for Swap A local zoo wants to keep track of how many pounds of food each of its three monkeys eats each day during a typical week. Write a program that stores this information in a two-dimensional 3 x 7 array, where each row represents a different monkey and each column represents a different day of the week. The monkeys are represented by integers 1, 2, and 3; the weekdays are "Sunday" "Monday" "Tuesday". "Wednesday. Thursday"....

  • Java code Guessing Game Refinement. (The user thinks of a number and the program guesses it)...

    Java code Guessing Game Refinement. (The user thinks of a number and the program guesses it) Program should be able to guess correctly in 7 tries or lower. Initialize a variable that represents the lowest possible number to 0 (what type should this be?) Initialize a variable that represent the highest possible number to 100 (what type should this be?) Initialize a Boolean variable that represents if we’ve achieved the correct guess to false Initialize a variable in which to...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT