Starting from:
$35

$29

PROGRAM #6 Solution

Outcomes:    
    • Write programs that obtain user input 
    • Write programs that manipulate String objects 
    • Write programs that use if and else statements for decision-making 
    • Write programs that use modules
    • Format and comment source code that adheres to a given set of formatting guidelines 

Assignment
    1. In a class named Triangles, write a program that displays three triangles with the selected characters. 
    2. In a class named EarthTemp, write a program to take a depth (in kilometers) inside the earth as input data; compute and display the temperature at this depth in degree Celsius and degree Fahrenheit.
    3. In a class named VolumeCalculator, write a program that calculates: a) the volume of a sphere, b) the volume of a cylinder, or c) the volume of a cube. First, the program asks the user to input one of the three possible options, if the user enters a different option, the program will show an error message and end the program. For each option, the program will ask the corresponding measures such as radius, height, side length; then it will calculate and display the result of the operation.
Requirements
    • In class Triangle,
        ◦ Create a method which draws one triangle given a character as argument.
        ◦ The program must call the drawing method three times with the corresponding characters.
    • In class EarthTemp,
        ◦ Create two methods:
            ▪ getCelsiusAtDepth – calculates and returns the Celsius temperature at a depth measured in kilometres. 
Celsius = 10 * depth + 20
            ▪ convertCelsiusToFahrenheit – converts a Celsius temperature to Fahrenheit.
Fahrenheit = 1.8 * Celsius + 32
    • In class VolumeCalculator: 
        ◦ The only valid options for the initial input are a, b, and c. Other options will raise an error message, even those which start with the character of a valid option i.e. car, boat, apple also raise an error message.
        ◦ The volume of a sphere must be calculated in a method with a return value, given the radius.
        ◦ The volume of a cylinder must be calculated in a method with a return value, given the radius and height. 
        ◦ The volume of a box must be calculated in a method with a return value, given the side length. 
        ◦ The input values can be of type double.
        ◦ The output should be presented with three decimal places.


Sample run
Your program should match this format as closely as possible. Note that some text shown inside the rectangles is there because the user typed it. You are not supposed to print those. 
class Triangle

Class EarthTemp




Class VolumeCalculator










Follow these steps to submit your work: 
    1. Create an empty folder named program6. 
    2. Put copies of your three source code files (.java) in the program6 folder. Do not put any other files in that folder. There should be exactly three .java files. 
    3. Compress the folder to create a zip file. Be sure it ends with .zip. 
    4. Submit only the zip file to the Canvas website. 

Note: If you submit your work and decide to modify one of your programs, you need to resubmit a new zip file containing all three source code files (even if you only modified one of them). Do not rename your source code files. Do not rename the zip file. Canvas may add a number to the name of your

More products