JFo 4 Practice
JFo 4 Practice
Practices - Section 4
Overview
In this practice, you will write methods that return values for the following scenarios:
Formula:
C=5/9*(F-32)
Formula:
Copyright © 2022, Oracle and/or its affiliates. Oracle, Java, and MySQL are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks of their respective owners.
3. Simulate the rolling of two 6-sided dice and display their sum.
Task
You must implement the following:
1. Write a java file, ComputeMethods.java and define the following three methods:
public double fToC(double degreesF)
public double hypotenuse(int a, int b)
public int roll()
Expected Output:
The ComputeMethods.java and TestClass.java files are available to help you get started.
Copyright © 2022, Oracle and/or its affiliates. Oracle, Java, and MySQL are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks of their respective owners. 2
Problem 2: Process a name
Overview
In this practice, you will develop a java program that processes a name entered by the user. The program does the following:
It reads the user's first and last name (read an entire line as a single string), then prints the last name followed by a comma and the first
initial. (Assume that the user types a valid name.)
Task
You must implement the following:
1. Have the user enter a name
2. Extract the first and last name from the name entered by the user
3. Use methods of String class to manipulate name as specified:
4. Display the name to the console
Expected Output:
Copyright © 2022, Oracle and/or its affiliates. Oracle, Java, and MySQL are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks of their respective owners. 3