Professional Documents
Culture Documents
Updated Flowchart & Coding
Updated Flowchart & Coding
Rent A Van wants a program that calculates the total cost of renting a van. Customers
pay a base fee plus a charge per mile driven. RM700 is the base fee, and the charge
per mile is based on the table below. Request the input from the user. If value entered
is not positive, ask user to re-enter the correct value and display text message. You
also need to use and apply basic loop structure.
0-99 RM 100
100-500 RM 320
#include<stdio.h>
int main ()
{
int mile;
float bill, fee=700, a=100, b=320, c=500;
while(mile<0)
{
printf("Please re-enter the value.\n");
main() ;
break;
}
return 0;
}
Scenario 2:
A student is only qualified for a scholarship if he/she has studied for more than 1 year,
CGPA is not less than 3.0 and guardian’s salary is less than RM1000. Otherwise,
display “You are not qualified for scholarship”.
Show the problem analysis, produce the pseudocode, draw the flowchart and write
the C program.
(Total marks:40)
#include<stdio.h>
int main ()
{
int month;
float CGPA;
int salary;
{
if (month<12 || CGPA<3.0 || salary>1000)
printf("You're not qualified");
else if (month>12 && CGPA>=3.0 && salary<1000)
printf("You're qualified ");
}
return 0;
}