Instructions:
- Fork this repository to your GitHub account.
- Clone the forked repository locally to your machine.
- Create a new branch named Feature01.
Objective:
Explore the behavior of the System.out.printf
function when displaying values with incorrect format specifiers in Java.
Printf Format Exploration:
- Use
printf
to display a value of typeint
using%f
. - Display a
double
using%d
. - Try using two format specifiers but provide only one value.
For each of the issues above, screenshot and add the error images to this repo named error01.png, error02.png, and error003.png or simply edit this README.md and use markdown to list the error messages received.
Your answers to this exercise should be added using Markdown into the project's README.md
file so that they get committed with the project's code..
Objective: Add a Java file to the src directory named TempConvert.java, and write a Java program to convert a temperature from Celsius to Fahrenheit. Remember, all Java programs need a main method because that's where every Java program starts!
Steps:
- Prompt the user for input.
- Read a
double
value from the keyboard. - Calculate the result using the formula:
F = C × 9/5 + 32
. - Format the output to one decimal place.
- Test the program by entering a temperature in Celsius.
Example Output:
Enter a temperature in Celsius: 24
24.0 C = 75.2 F
Hint:
- Be careful not to use integer division!
- Format specifiers would be a great choice for #4!
Objective: Write a Java program that converts a total number of seconds to hours, minutes, and seconds.
Steps:
- Prompt the user for input.
- Read an integer from the keyboard (total number of seconds).
- Calculate the result using the modulus operator.
- Use printf to display the output in the format: "5000 seconds = 1 hours, 23 minutes, and 20 seconds".
Enter a total number of seconds: 5000
5000 seconds = 1 hours, 23 minutes, and 20 seconds
Hint:
- The modulus operator is the remainder operator and will simplify the calculation.
Follow these steps for submission:
- Create a Feature01 branch of your code if you haven't already.
- Commit your working code to your local copy/Feature01 branch.
- Push it to your Remote/origin branch (i.e., GitHub: Feature01 -> origin/Feature01).
- Issue a Pull request to my instructor repo.
- Make sure to COPY the Pull request URL and submit it for the lab/assignment in Canvas.