Question: Question : Create a flowchart to describe logic algorithm of this program (this program use array and loops). #include #include #include using namespace std; float

Question : Create a flowchart to describe logic algorithm of this program (this program

use array and loops).

#include

#include

#include

using namespace std;

float calcStudentLoan (float duit, float simpanan) //function to calculate the money that the student

should save every semester

{

if (duit >= 5000) // condition for percentage of the saving for each amount of loan the

student will get

{

simpanan = 0.3 * duit;

}

else if (duit >= 3000)

{

simpanan = 0.1 * duit;

}

else

{

simpanan = 0.05 * duit;

}

return simpanan;

}

float calcTotalBalance (float money, string respond)// fuction to calculate the money spending for a

day

{

float total = 0.0;

do

{

cout << " How much you want to spend : " ;

cin >> money;

total = money + total; //calculation of the total spend

cin.ignore();

cout << "Do you want to spend more? "<< endl << " Enter 'y' to continue and 'n' to

stop :";

getline(cin,respond);

} while (respond == "y");

return total;

}

int main ()

{

//declaration of the variable involve

float expenses, saved, saving, spend, sum,totalBalance;

float total = 0.0;

float loanbalance = 0.0;

string answer, respond;

char username [20]; // array

//program input

cout << "Enter 'y' to start. : ";

getline(cin,respond);

cout << "Type your username (6-12 characters) : " ;

cin.getline(username,20);

cout << "Enter your student loan: RM " ;

cin >> expenses;

sum = calcTotalBalance (spend, answer);

saving = calcStudentLoan (expenses, saved);

loanbalance = expenses - saving;

total = loanbalance - sum;

// program output

cout << fixed<

cout << "------------------------------------------------------------" << endl;

cout << setw (40) << "STUDENT SMART SPENDING " << endl;

cout << "------------------------------------------------------------" << endl;

cout << setw (30) << "Welcome " << username << "!" << endl;

cout << " Your loan : RM " << expenses << endl;

cout << " You are advice to save : RM " << saving << endl;

cout << " Your balance after saving : RM " << loanbalance<< endl;

cout << " Your spending for today : RM " << sum << endl;

cout << " Your balance after spending : RM " << total<< endl;

cout << setw (40) << " Goodluck with your saving " << username << ",make sure to spend

wisely! " << endl;

cout << "------------------------------------------------------------" << endl;

return 0;

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!