Hw3Flowchart

Submitted by: Submitted by

Views: 10

Words: 295

Pages: 2

Category: Science and Technology

Date Submitted: 10/10/2015 10:00 PM

Report This Essay

No

No

Yes

Yes

No

No

Yes

Yes

End

End

Does Days==howmanydays?

Does Days==howmanydays?

Is Days<=365?

Is Days<=365?

Set money=15.00

Set money=15.00

Set money=money*Days

Set money=money*Days

Output “Amount on money on Day: x is $x.xx”

Output “Amount on money on Day: x is $x.xx”

Input howmanydays

Input howmanydays

Start

Start

Output “How many days would you like to save $15.00?”

Output “How many days would you like to save $15.00?”

Pseudocode

//This program will calculate the amount of money a user has saved, if the user is saving $15 a day, for x amount of days for up to one year.

BEGIN

//Declare variables

Declare money as float

Declare Days, howmanydays as integer

//Ask for user input

Output “How many days would you like to save $15.00?”

Input howmanydays

FOR (Days=1; Days<=365; Days++)

Set money=15.00

Set money=money*Days

Output "Amount of money on Day: X, is $x.xx"

IF (Days==howmanydays) THEN

End loop

END IF

END FOR

END

C Code

#include <stdio.h>

#include <math.h>

int main(void) {

//Declare variables

float money;

int Days, howmanydays;

//Prompt for user input

printf("How many days would you like to save $15.00? \n");

scanf(" %d", &howmanydays);

for (Days=1; Days<=365; Days++){ //Begins FOR loop

money=15.00; //Set initial value of money

money=money*Days; //equation for daily value of money

printf("Amount of money on Day:%d, is $%.2f \n", Days,money); /*prints out the amount of money saved for x amount of days*/

if (Days==howmanydays) /*Selection statement, provides user option for how many days to save*/

break;

}

return 0;

}