Advertisement
miknik97

pp_01

Mar 12th, 2018
381
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.67 KB | None | 0 0
  1. import java.util.Scanner;
  2. public class Main
  3. {
  4.     public static void main(String[] args)
  5.     {
  6.         for(int i=0; i<11; i++) System.out.print("* ");
  7.         System.out.println();
  8.         System.out.println("* PROGRAM - SREDNIA *");
  9.         for(int i=0; i<11; i++) System.out.print("* ");
  10.         System.out.println();
  11.         System.out.println();
  12.  
  13.         Scanner klawiatura=new Scanner(System.in);
  14.         int wybor=0;
  15.         String imie;
  16.         System.out.print("Podaj imie: ");
  17.         imie=klawiatura.next();
  18.  
  19.         do
  20.         {
  21.             System.out.println("Witaj "+imie+"! Co chcesz zrobic?");
  22.             System.out.println("1. Oblicz srednia");
  23.             System.out.println("2. Zmien imie");
  24.             System.out.println("3. Koniec");
  25.             System.out.println();
  26.  
  27.  
  28.             System.out.print("Twoj wybor: ");
  29.             wybor=klawiatura.nextInt();
  30.             switch(wybor)
  31.             {
  32.                 case 1:
  33.                     double a, b, c, srednia;
  34.                     System.out.print("Podaj a: ");
  35.                     a=klawiatura.nextDouble();
  36.                     System.out.print("Podaj b: ");
  37.                     b=klawiatura.nextDouble();
  38.                     System.out.print("Podaj c: ");
  39.                     c=klawiatura.nextDouble();
  40.                     srednia=(a+b+c)/3.0;
  41.                     System.out.println("Srednia: "+srednia+"\n");
  42.                     break;
  43.  
  44.                 case 2:
  45.                     System.out.print("Podaj imie: ");
  46.                     imie=klawiatura.next();
  47.                     System.out.println();
  48.                     break;
  49.             }
  50.         } while(wybor!=3);
  51.  
  52.     }
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement