OBJECT ORIENTED IN JAVA Example for VERSION 1: Welcome to Nick's Neon Tubing Calculator Enter the shape type (R, S, C, T, L, Q): R Enter Height and Width of Rectangle: 6.5 12 The perimeter of a 6.5 x 12 rectangle is 37.0 Enter the shape type (R, S, C, T, L, Q): C Enter Diameter: 12 The circumference of circle with diameter 12 is 37.7 Enter the shape type (R, S, C, T, L, Q): Q Shapes Needed 37.0 - rectangle, 6.5 x 12 37.7 - circle, diameter 12 --------------------------- 74.7 Total Length Thank You there is a version 2 as well, if you look at the pictures. Every person I have asked to help has either not made it object oriented or that code did not work. PLEASE help.
OBJECT ORIENTED IN JAVA
Example for VERSION 1:
Welcome to Nick's Neon Tubing Calculator
Enter the shape type (R, S, C, T, L, Q):
R
Enter Height and Width of Rectangle:
6.5 12
The perimeter of a 6.5 x 12 rectangle is 37.0
Enter the shape type (R, S, C, T, L, Q):
C
Enter Diameter:
12
The circumference of circle with diameter 12 is 37.7
Enter the shape type (R, S, C, T, L, Q):
Q
Shapes Needed
37.0 - rectangle, 6.5 x 12
37.7 - circle, diameter 12
---------------------------
74.7 Total Length
Thank You
there is a version 2 as well, if you look at the pictures. Every person I have asked to help has either not made it object oriented or that code did not work. PLEASE help.
Algorithm:
- Start the program.
- Declare and initialize a Scanner object named "input" to read input from the console.
- Declare and initialize a double variable named "totalLength" to keep track of the total length of neon tubing required.
- Print a welcome message to the user.
- Enter a while loop that will continue until the user enters "Q" to quit the program.
- Inside the loop, prompt the user to enter the shape type they want to calculate the perimeter of (R, S, C, T, L, Q).
- Convert the input to upper case using the toUpperCase() method to avoid case sensitivity issues.
- Use a switch statement to execute different code based on the shape type entered by the user.
- For each case in the switch statement, prompt the user to enter the required parameters for the shape type and perform the appropriate calculation to find the perimeter of the shape. Also, add the perimeter to the total length variable.
- If the user enters an invalid shape type, print an error message.
- After the switch statement, use input.nextLine() to clear the input buffer and prepare for the next iteration of the loop.
- Once the user enters "Q" to quit the program, print out the total length of neon tubing required and a thank you message.
- End the program.
Step by step
Solved in 4 steps with 4 images