Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

JAVA Flowchart Problems 1

Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

Dr.

Ali Alsaffar 5

2 Flow Charts
1. In a game center, a child can play the games if the child’s age is above 5 years and the height is above 120 cm.
DRAW A FLOWCHART OF A PROGRAM that will ask the user to enter the child age and height, then
the program should print a message saying ”Yes, You can Play” if the child can play the game; otherwise it
should print a message “Sorry, you cannot play”.
2. Draw a flowchart for a program that:
Prompts the user to enter from the keyboard three numbers a, b, and c representing the sides of a triangle. Based
on the length of a, b, and c, print the type of the triangle:
• Equilateral: if the three sides are equal.
• Not Equilateral: if the three sides are not equal.
Afterwards,display on screen the triangle circumference which is equal to the sum of a, b, and c.
3. Nasser currently runs a car rental dealership and wishes to recommend a car to renters based on temperature of
the location they want to visit. Draw a flowchart for a program to read a temperature of a location and print
the recommended type as shown in the table below:

Temperature) Recommended Car


Below 60 Truck
From 60 to 80 ) SUV
Above 80 Convertible

4. Draw a flowchart for a program to do the following:

(a) Prompts the user to enter a decimal value and a character code.
(b) If code is equal to ‘R’, the program calculates and prints the area of a circle and value is considered as the
radius. The area of a circle is calculated as P I × radius2 , where PI is equal to 3.14159.
(c) If code is ‘Q’, the program calculates and prints the area of a square and value is considered as the side.
The area of a square is calculated as side2 .
(d) Any other code, display an error message and end the program.
Example:
If the input is 2.3 and R, then the output is ‘The area of a circle is 16.619’ and if the input is 2.3 and Q, then
the output is ‘The area of a square is 5.29’.
5. The selling price of an apartment depends on the area of the apartment and the floor number where the apartment
is located.
Draw a flowchart for a program that:
(a) Prompts the user to enter from the keyboard:
• The area by square meter of the apartment.
• The floor number where the apartment is located.
(b) Calculates the total price of the apartment based on the apartment area and the floor number as shown
below:
Area (square meter) Price for square meter
Upto 150 BD. 500 for each square meter
Between 151 and 200 (inclusive) BD. 450 for each square meter
Over 200 Display apartment not available
(c) Calculates additional Price By Floor using the floor number of the apartment multiplied by BD. 1000.
(d) Display the total price if applicable.
Apartment 1: Area 120 in Floor 0, the total price = 120 × 500 + 1000 × 0 = 60, 000.
Apartment 2: Area 160 in Floor 5, the total price = 160 × 450 + 1000 × 5 = 77, 000.
6. Draw a flowchart for a program that:

(a) Prompts the user to enter from the keyboard the employees Salary in BD.
Dr. Ali Alsaffar 6

(b) Calculates the Tax as shown in the table below:


Salary Range in BD Tax
Between 0 and 500 0.05 × Salary
More than 500 and less than 1000 0.08 × Salary
1000 or Above 0.09 × Salary
(c) Displays the value of Tax.
(d) Displays the value of Net Salary = Salary - Tax.
Example: If Salary is 600, then Tax is 0.08 × 600 = 48 and Net Salary is 60048 = 552.
7. Suppose you want to buy some pizzas from Cool Pizza restaurant.
Draw a flowchart for a program that:

(a) Prompts the user to enter from the keyboard the size, the quantity and service charge of a pizza.
(b) Displays an error message and exits the program if the size of the pizza is less than 6 inches.
(c) Calculates the Total Price as shown in the table below:
Size of Pizza Total Price BD
6 to 10 inches 2.5 × quantity
greater than 10 inches 3.5 × quantity

(d) Displays the value of Net Price = Total Price + Service charge.

Example: If the size of the pizza is 7 inches, the quantity is 5 and service charge is BD. 0.850, then the Total
Price is 2.5 × 5 = 12.5 and the Net Price is 12.5 + 0.95 = 13.35.
8. Draw a flowchart for a program that:
(a) Prompts the user to enter from the keyboard ONE of the following characters: T or C followed by two
numbers x and y.
(b) Calculates the value of f as follows:

x − y, if T is entered;



 x−y
f= , if C is entered;

 x+y

Display “Error”, If other char is entered.

(c) Displays on the screen: The entered character, the values of x and y, and the value of f .

9. The “Burger & Fries” restaurant is running a promotion in which delivery orders receive a discount while dine-in
orders receive no discount. Draw a flowchart that displays the discount percentage. The program should first
ask the user for two values: order type (delivery or dine-in), and the number of burgers to be ordered. The
program will then determine the discount as follows:
(a) Dine-in orders receive no discount.
(b) Delivery orders of up to two burgers receive 25% discount.
(c) Delivery orders of larger than two burgers receive 40% discount.
The program will select from above which discount percentage to display.

You might also like