In QBASIC ONLY NOT JAVA, design and create a program named \" Final_1.bas \" wit
ID: 665920 • Letter: I
Question
In QBASIC ONLY NOT JAVA, design and create a program named "Final_1.bas" with the following requirements.
Have the program display "Welcome to the RCC Geometry Calculator".
The program will allow the user to calculate the area of various geometrical shapes.
The program should ask the user which shape they want to calculate the area of:
(1) Calculate the Area of a Circle
(2) Calculate the Area of a Rectangle
The program should allow the user to enter their choice.
The program should then react to the input given by the user:
If the user entered 1, the program should ask for the radius of the circle, and calculate the area of the circle using the following equation: [ area = 3.14 * r^2 ]. The program should display the calculated area.
If the user entered 2, the program should ask for the length and width of the rectangle, and then pass the provided length and width to a function named calcRectangleArea. The function, calcRectangleArea, should calculate the area of the rectangle using the following equation: [ area = length X width ]. The function MUST return the calculated area and then the program should display the calculated area.
Explanation / Answer
DIM LENTH AS INTEGER
DIM BREADTH AS INTEGER
DIM RADIUS AS INTEGER
DIM AREA AS DOUBLE
DECLARE FUNCTION calcRectangleArea ( LENGTH, BREADTH )
CLS
PRINT "Welcome to the RCC Geometry Calculator"
PRINT " A) CALCULATE THE AREA OF CIRCLE"
PRINT " B) CALCULATE THE AREA OF TRIANGLE"
INPUT "ENTER SELECTION:";SEL
SEL=UCASE$(SEL)
PRINT
SELECT CASE SEL
CASE "A"
INPUT "RADIUS: "; RADIUS
PRINT "AREA :"; 3.14*RADIUS*RADIUS
CASE "B"
INPUT "LENGTH:";LENGTH
INPUT "BREADTH:";BREADTH
PRINT "AREA:";calcRectangleArea(LENGTH,BREADTH) //Calling a function to calculate the area
END SELECT
FUNCTION calcRectangleArea(LENGTH,BREADTH) //Function Definition
AREA= A*B
END FUNCTION
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.