Draw a flowchart from this algorithm.
Start
Declare variable kilowattHour
Declare variable amountDue
Declare variable i
for i=1 to 100 Step 1
Read kilowattHour from the user
if kilowattHour<=300 then
amountDue=kilowattHour*25.00
else
amountDue=300*25.00+(kilowattHour-300)*30.00
End if
Display amountDue
end for
Stop
#include<iostream>
using namespace std;
int main()
{
int kilowarttHour;
int amountDue;
int i;
for(int i=1;i<100;i++){
cout<<"Enter the kilowartHour: ";
cin>>kilowarttHour;
if(kilowarttHour<=300){
amountDue=kilowarttHour*25;
cout<<"amountDue"<<amountDue<<endl;
}
else{
amountDue=300*25.00+(kilowarttHour-300)*30.00;
cout<<amountDue<<endl;
}
}
}
Comments
Leave a comment