Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class myProgram {
- static Scanner input = new Scanner(System.in);
- static calculate cObj = new calculate();
- public static void main(String[] args) {
- System.out.println("What do you want to do:\n(1) Calculate KE\n(2) Calculate M\n(3) Calculate V\n");
- int choice = input.nextInt();
- switch (choice) {
- case 1:
- kineticenergy();
- break;
- case 2:
- mass();
- break;
- case 3:
- velocity();
- break;
- default:
- System.out.println("Error");
- break;
- }
- System.out.println("\nType (1) to start again. Type (2) to quit");
- int again = input.nextInt();
- switch (again) {
- case 1:
- System.out.println("\n\n\n\n\n");
- main(args);
- break;
- case 2:
- System.exit(0);
- break;
- default:
- System.out.println("Error");
- break;
- }
- }
- private static void velocity() {
- double kineticenergy, mass;
- System.out.println("Enter mass: (kg)");
- mass = input.nextDouble();
- System.out.println("Enter kinetic energy: (J)");
- kineticenergy = input.nextDouble();
- calculate.calculateV(mass, kineticenergy);
- }
- private static void mass() {
- double kineticenergy, velocity;
- System.out.println("Enter kinetic energy: (J)");
- kineticenergy = input.nextDouble();
- System.out.println("Enter velocity: (m/s)");
- velocity = input.nextDouble();
- calculate.calculateM(kineticenergy, velocity);
- }
- private static void kineticenergy() {
- double mass, velocity;
- System.out.println("Enter mass: (Kg)");
- mass = input.nextDouble();
- System.out.println("Enter velocity: (m/s)");
- velocity = input.nextDouble();
- calculate.calculateKE(mass, velocity);
- }
- }
Add Comment
Please, Sign In to add comment