7.3.. Napisati program za ispis uspjeha, prema slijedeæoj tabeli:
Listing programa:
//07311004
package zad1;
import java.util.Scanner;
public class p07311004 {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
System.out.println("Unesi k (1-3): ");
int k = input.nextInt();
int y;
switch (k) {
case 1:
y = k + 2;
System.out.println(y);
break;
case 2:
y = k - 2;
System.out.println(y);
break;
case 3:
y = k * 2;
System.out.println(y);
break;
default:
System.out.println("K ima vrijednosti od 1 do 3.");
}
}
}
Ispis na ekranu:
Index
|