Question: i am working on a java program that prompts a user to choose whether the input will be a wevelenght value or a frequency value.

i am working on a java program that prompts a user to choose whether the input will be a wevelenght value or a frequency value. then prints out the description of the corresponding part of the electromagnetic spectrum. This is what i have done so far but its not compling:

// import Scanner import java.util.Scanner:

class ElectroMagneticSpectrum { public static void main(String[] a) { double num,i; Scanner input = new Scanner(System.in);

System.out.println("To enter the wavelength value Press 1 "); System.out.println("To enter the frequency value Press 2 "); i= input.nextInt(); if(i==1) { System.out.println("Enter the wavelength value :"); }else { System.out.println("Enter the frequency value :"); num1 = input.nextDouble(); } switch(i) { case 1 : if(num>=1/10) { System.out.println("Radio Waves"); } else if(num >= 1/1000 && num < 1/10 ) { System.out.println("Microwaves"); } else if (num >= 7/10000000 && num < 1/1000) { System.out.println("Infrared "); } else if (num >= 4/10000000 && num < 7/10000000) { System.out.println("Visible light"); } else if (num >= 1/100000000 && num < 4/10000000) { System.out.println("Ultraviolet "); } else if (num >= 1/100000000000 && num < 1/100000000) { System.out.println("X-rays"); } else if (num < 1/100000000000) { System.out.println("Gamma Rays"); } break ; case 2 : if(num < 3*1000000000) { System.out.println("Radio Waves"); } else if(num >= 3*1000000000 && num < 3*100000000000 ) { System.out.println("Microwaves"); } else if (num >= 3*100000000000 && num < 4*100000000000000) { System.out.println("Infrared "); } else if (num >= 4*100000000000000 && num < 7.5*100000000000000) { System.out.println("Visible light"); } else if (num >= 7.5*100000000000000 && num < 3*10000000000000000) { System.out.println("Ultraviolet "); } else if (num >= 3*10000000000000000 && num < 3*10000000000000000000) { System.out.println("X-rays"); } else if (num >= 3*10000000000000000000) { System.out.println("Gamma Rays"); } break ;

} }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!