Question: Start with a hello world program in Eclipse. Add code to ask the user for three numbers, and then display the number that is the
Start with a hello world program in Eclipse.
Add code to ask the user for three numbers, and then display the number that is the largest.
I want to make sure the code is correct
my code:
package test3; import java.util.Scanner;
public class TestStart {
public static void main(String{[]args) { System.out.println("Hello World"); public class Largest {
public static void main(String[] args) {
double n1 = -4.5, n2 = 3.9, n3 = 2.5;
if( n1 >= n2 && n1 >= n3) System.out.println(n1 + " is the largest number.");
else if (n2 >= n1 && n2 >= n3) System.out.println(n2 + " is the largest number.");
else System.out.println(n3 + " is the largest number."); } } } }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
