Guest User

Untitled

a guest
Jan 16th, 2019
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.66 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class myProgram {
  4.    
  5.     static Scanner input = new Scanner(System.in);
  6.     static calculate cObj = new calculate();
  7.    
  8.     public static void main(String[] args) {
  9.        
  10.         System.out.println("What do you want to do:\n(1) Calculate KE\n(2) Calculate M\n(3) Calculate V\n");
  11.         int choice = input.nextInt();
  12.         switch (choice) {
  13.         case 1:
  14.             kineticenergy();
  15.             break;
  16.         case 2:
  17.             mass();
  18.             break;
  19.         case 3:
  20.             velocity();
  21.             break;
  22.         default:
  23.             System.out.println("Error");
  24.         break;
  25.         }
  26.         System.out.println("\nType (1) to start again. Type (2) to quit");
  27.         int again = input.nextInt();
  28.         switch (again) {
  29.         case 1:
  30.             System.out.println("\n\n\n\n\n");
  31.             main(args);
  32.             break;
  33.         case 2:
  34.             System.exit(0);
  35.             break;
  36.         default:
  37.             System.out.println("Error");
  38.         break;
  39.         }
  40.        
  41.     }
  42.  
  43.     private static void velocity() {
  44.        
  45.         double kineticenergy, mass;
  46.         System.out.println("Enter mass: (kg)");
  47.         mass = input.nextDouble();
  48.         System.out.println("Enter kinetic energy: (J)");
  49.         kineticenergy = input.nextDouble();
  50.         calculate.calculateV(mass, kineticenergy);
  51.     }
  52.  
  53.     private static void mass() {
  54.        
  55.         double kineticenergy, velocity;
  56.         System.out.println("Enter kinetic energy: (J)");
  57.         kineticenergy = input.nextDouble();
  58.         System.out.println("Enter velocity: (m/s)");
  59.         velocity = input.nextDouble();
  60.         calculate.calculateM(kineticenergy, velocity);
  61.     }
  62.  
  63.     private static void kineticenergy() {
  64.        
  65.         double mass, velocity;
  66.         System.out.println("Enter mass: (Kg)");
  67.         mass = input.nextDouble();
  68.         System.out.println("Enter velocity: (m/s)");
  69.         velocity = input.nextDouble();
  70.         calculate.calculateKE(mass, velocity);
  71.     }
  72. }
Add Comment
Please, Sign In to add comment