I need some help with Java.
I am an AP Computer Science student and cannot get a piece of code to work. The goal is to use a scanner class to open up one of two classes written. i have been studying my code and cannot figure out what is wrong. Any suggestions?
import java.util.Scanner;
public class Interface {
public static void main (String[] args){
//Define Final Variables
final int mph = 1;
final int mpm = 2;
//Display Message On Execution
System.out.println(”Please Enter ‘1′ to Convert From MPH to MPM”);
System.out.println(”Please Enter ‘2′ to Convert From MPM to MPH”);
//Read User Input
Scanner in = new Scanner(System.in);
int s = in.nextInt();
//Select Which Conversion Class to Use
if (s == mph)
new MPH();
if (s == mpm)
new MPM();
//Checks for Invalid User Input
if (s!=mph || s!=mpm)
System.out.println(”Error 404. File not found.”);
}
}
This closed post was written 11 months, 3 weeks ago | V/U/S: 104, 2, 1 | Edit Post | Report Post
Reciprocity (0)
Since writing this post digitalsamurai0 may have helped people, but has not within the last 4 days. digitalsamurai0 is a verified member, has been around for 1 year and has 1 posts and 1 replies to their name.
Invite Others to Help
Seeing as this post is closed, no invites are allowed.
