Facebook
From Torrid Horse, 9 Years ago, written in Java.
Embed
Download Paste or View Raw
Hits: 562
  1. import java.util.Scanner;
  2.  
  3. public class Mennu {
  4.    
  5.     public static void main(String[] args)
  6.     {
  7.         double a=0,b=0,x=0;
  8.         int result=1;
  9.         String imie;
  10.         Scanner skaner = new Scanner (System.in);
  11.        
  12.         while (result > 0 )
  13.         {
  14.             System.out.println("***************************");
  15.             System.out.println("|--------Menu--------------|");
  16.             System.out.println("|----- 1 - powitanie ------|");
  17.             System.out.println("|----- 2 - galony I litry--|");
  18.             System.out.println("|----- 3 - objetosc walca--|");
  19.             System.out.println("|----- 0 - koniec programu-|");
  20.             System.out.println("****************************");
  21.            
  22.             if (skaner.hasNextInt())
  23.             {
  24.                 result= skaner.nextInt();
  25.             }
  26.            
  27.             switch (result)
  28.            
  29.             {
  30.                 case 1:
  31.                     System.out.println("Podaj swoje imie");
  32.                    
  33.                     imie = skaner.nextLine();
  34.                     imie = skaner.next();
  35.                     System.out.println("Witaj " + imie);
  36.                     break;
  37.                    
  38.                    
  39.                 case 2:
  40.                     System.out.println("Wybrales galony i litry");
  41.                     System.out.println("Podaj liczbe galonow a = ");
  42.                     a = skaner.nextInt();
  43.                     b=a*3.7854;
  44.                     System.out.println(a + " galonow to  " +b + " litrow.");
  45.                     break;
  46.                    
  47.                    
  48.                 case 3:
  49.                     System.out.println("Objetosc walca");
  50.                     System.out.println("Podaj promien walca a = ");
  51.                     a = skaner.nextInt();
  52.                     System.out.println("Podaj wysokosc walca b = ");
  53.                     b = skaner.nextInt();
  54.                     x =3.14*a*a*b;
  55.                     System.out.println("Objetosc walca o promieniu "+ a +" i wysokosci " + b+ " wynosi " + x);
  56.                     break;
  57.                    
  58.                    
  59.                 case 0:
  60.                     System.out.println (" podales " + x);
  61.                     System.out.println("Wychodze z programu");
  62.                     break;
  63.                    
  64.                 default:
  65.                     System.out.println("Nieprzewidziana sytuacja");
  66.             }
  67.         }
  68.     }
  69. }