Starting from:

$30

CSC220-Lab 4 Java Programs Solved

Write complete Java programs.

 

Java programs:

1.     Write a Java application Convert.java that converts miles to kilometers. (One mile equals 1.60935 kilometers). Use the command line argument to read the mile’s value from the user as a floating point value.  

 

2.     Write a Java program Calculate.java that prompts for and uses scanner to read a value representing a number of seconds, and then print the equivalent amount of time as a combination of hours, minutes, and seconds. (For example, 9999 seconds is equivalent to 2 hours, 46 minutes, and 39 seconds).  

 

Compiling and running Java programs (reminder):

 

1.     Open a terminal window. Use the cd command to change to the directory in which you saved your program.

 

2.     Use the javac command to compile your program: javac Convert.java

 

3.     If you don’t get any errors, use the java command to run your program: java Convert

 

4.     Repeat the steps for the second program.

More products