online compiler and debugger for c/c++

code. compile. run. debug. share.
Source Code    Language
import java.util.Scanner; public class Main { private String genre; private String title; private String time; private double cost; private int confirmationNo = (int) Math.random() * 1000; private static Main obj = new Main(); private static Scanner console = new Scanner(System.in); public static void setGenre(String genre){ genre = genre; } public static void setTitle(String title){ title = title; } public static void sleepTimer(int timeToSleep){ try{ Thread.sleep(timeToSleep); }catch(Exception e){ e.toString(); } } public static void showEnums(){ System.out.println("Movie Genres:"); for(Prac p : Prac.values()){ sleepTimer(1000); System.out.println(p + " "); sleepTimer(1000); } System.out.println(); for(Prac p : Prac.values()){ System.out.println(p + ": Movie Titles:"); sleepTimer(1000); System.out.println(p.printArr()); } for(Prac p : Prac.values()){ System.out.println(p + ": Movie Times:"); sleepTimer(1000); System.out.println(p.printTimes()); } } public static void initiate(){ System.out.println("Would you like to see our movie options?"); String answer = console.nextLine(); if(answer.equalsIgnoreCase("y")){ showEnums(); System.out.println(); keyTitle(); }//if selection equals no tie in the program initially made } public static void keyTitle(){ Scanner console = new Scanner(System.in); System.out.println("Type in a Genre:"); String genre = console.nextLine(); boolean isPresent = false; for(Prac p : Prac.values()){ if(genre.equalsIgnoreCase(p.name())){ isPresent = true; break; } } if(isPresent){ obj.setGenre(genre); System.out.println("Type in a movie title:"); String movie = console.nextLine(); validateTitle(movie); }else{ System.out.println("You have entered an invalid entry. Try again."); keyTitle(); } } public static void validateTitle(String title){ for(Prac p : Prac.values()){ boolean validator = p.selectMovie(title); if(validator){ obj.setTitle(title); } } } public static void main(String[] args) throws Exception { //initiate(); } }
public enum Prac { HORROR(){ String[] movies = {"Holloween", "Final Destination", "Resident Evil", "Thirty Days of Night", "The Wicked"}; String[] movieTime = {"2:00pm", "3:00pm", "5:00pm", "7:00pm", "9:00pm", "11:00pm"}; double price = 9.50; public String printArr(){ for(int i = 0; i < movies.length; i++){ System.out.println(movies[i] + " "); Main.sleepTimer(1000); } return ""; } public String printTimes(){ for(int i = 0; i < movieTime.length; i++){ System.out.print(movieTime[i] + " "); Main.sleepTimer(1000); } return ""; } public boolean selectMovie(String selection){ for(int i = 0; i < movies.length; i++){ if(movies[i] == selection){ return true; } } return false; } }, COMEDY(){ String[] movies = {"The Bucket List", "Def Comedy Jam", "Rescue From Gilligan's Island", "Easy Money", "The Hustle"}; String[] movieTime = {"2:30pm", "3:30pm", "5:30pm", "7:30pm", "9:30pm", "11:30pm"}; double price = 9.50; public String printArr(){ for(int i = 0; i < movies.length; i++){ System.out.println(movies[i] + " "); Main.sleepTimer(1000); } return ""; } public String printTimes(){ for(int i = 0; i < movieTime.length; i++){ System.out.print(movieTime[i] + " "); Main.sleepTimer(1000); } return ""; } public boolean selectMovie(String selection){ for(int i = 0; i < movies.length; i++){ if(movies[i] == selection){ return true; } } return false; } }, ROMANCE(){ String[] movies = {"Love Don't Cost a Thing", "Step Up All In", "The Blue Lagoon", "The Choice", "A Spare Room"}; String[] movieTime = {"12:10pm", "2:10pm", "4:10pm", "6:10pm", "8:10pm", "10:10pm"}; double price = 9.50; public String printArr(){ for(int i = 0; i < movies.length; i++){ System.out.println(movies[i] + " "); Main.sleepTimer(1000); } return ""; } public String printTimes(){ for(int i = 0; i < movieTime.length; i++){ System.out.print(movieTime[i] + " "); Main.sleepTimer(1000); } return ""; } public boolean selectMovie(String selection){ for(int i = 0; i < movies.length; i++){ if(movies[i] == selection){ return true; } } return false; } }, ACTION(){ String[] movies = {"Under Siege", "The Long Kiss Goodnight", "Edge of Extinction", "Collateral Damage", "The Legend of Hercules"}; String[] movieTime = {"11:45am", "1:45pm", "3:45pm", "5:45pm", "7:45pm", "9:45pm"}; double price = 9.50; public String printArr(){ for(int i = 0; i < movies.length; i++){ System.out.println(movies[i] + " "); Main.sleepTimer(1000); } return ""; } public String printTimes(){ for(int i = 0; i < movieTime.length; i++){ System.out.print(movieTime[i] + " "); Main.sleepTimer(1000); } return ""; } public boolean selectMovie(String selection){ for(int i = 0; i < movies.length; i++){ if(movies[i] == selection){ return true; } } return false; } }, ADVENTURE(){ String[] movies = {"Gods of Egypt", "The Last Witch Hunter", "The Hunger Games: Mockingja", "10,000 BC", "Lost in Space"}; String[] movieTime = {"12:15pm", "1:15pm", "2:15pm", "3:15pm", "4:15pm", "5:15pm"}; double price = 9.50; public String printArr(){ for(int i = 0; i < movies.length; i++){ System.out.println(movies[i] + " "); Main.sleepTimer(1000); } return ""; } public String printTimes(){ for(int i = 0; i < movieTime.length; i++){ System.out.print(movieTime[i] + " "); Main.sleepTimer(1000); } return ""; } public boolean selectMovie(String selection){ for(int i = 0; i < movies.length; i++){ if(movies[i] == selection){ return true; } } return false; } }, CRIME(){ String[] movies = {"A Man Apart", "New Jack City", "Cradle 2 the Grave", "I Am Wrath", "Murder at 1600"}; String[] movieTime = {"2:40 pm", "3:40 pm", "5:40 pm", "7:40 pm", "9:40 pm", "11:40 pm"}; double price = 9.50; public String printArr(){ for(int i = 0; i < movies.length; i++){ System.out.println(movies[i] + " "); Main.sleepTimer(1000); } return ""; } public String printTimes(){ for(int i = 0; i < movieTime.length; i++){ System.out.print(movieTime[i] + " "); Main.sleepTimer(1000); } return ""; } public boolean selectMovie(String selection){ for(int i = 0; i < movies.length; i++){ if(movies[i] == selection){ return true; } } return false; } }; private String[] movies; public abstract String printArr(); public abstract String printTimes(); public abstract boolean selectMovie(String selection); }
public enum Planet { MERCURY (3.303e+23, 2.4397e6), VENUS (4.869e+24, 6.0518e6), EARTH (5.976e+24, 6.37814e6), MARS (6.421e+23, 3.3972e6), JUPITER (1.9e+27, 7.1492e7), SATURN (5.688e+26, 6.0268e7), URANUS (8.686e+25, 2.5559e7), NEPTUNE (1.024e+26, 2.4746e7); private final double mass; // in kilograms private final double radius; // in meters Planet(double mass, double radius) { this.mass = mass; this.radius = radius; } private double mass() { return mass; } private double radius() { return radius; } // universal gravitational constant (m3 kg-1 s-2) public static final double G = 6.67300E-11; double surfaceGravity() { return G * mass / (radius * radius); } double surfaceWeight(double otherMass) { return otherMass * surfaceGravity(); } public static void main(String[] args) { if (args.length != 1) { System.err.println("Usage: java Planet <earth_weight>"); System.exit(-1); } double earthWeight = Double.parseDouble(args[0]); double mass = earthWeight/EARTH.surfaceGravity(); for (Planet p : Planet.values()) System.out.printf("Your weight on %s is %f%n", p, p.surfaceWeight(mass)); } }

Compiling Program...

Command line arguments:
Standard Input: Interactive Console Text
×

                

                

Program is not being debugged. Click "Debug" button to start program in debug mode.

#FunctionFile:Line
VariableValue
RegisterValue
ExpressionValue