Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- package skola;
- import java.util.Scanner;
- /**
- *
- * @author Felix 1
- */
- public class Övning88 {
- /**
- * @param args the command line arguments
- */
- public static void main(String[] args) {
- Scanner inmatning = new Scanner(System.in);
- char fortsätt = 'j';
- int tal1 = 0;
- int tal2 = 0;
- int räknesätt;
- int resultat = 0;
- do
- {
- System.out.print("Tal 1: "); tal1 = inmatning.nextInt();
- System.out.print("Tal 2: "); tal2 = inmatning.nextInt();
- System.out.print("Räknesätt (1.+ 2.- 3.* 4./): "); räknesätt = inmatning.nextInt();
- switch(räknesätt)
- {
- case 1:
- resultat = tal1 + tal2;
- break;
- case 2:
- resultat = tal1 - tal2;
- break;
- case 3:
- resultat = tal1 * tal2;
- break;
- case 4:
- resultat = tal1 / tal2;
- break;
- default:
- }
- System.out.println("Resultat: " + resultat);
- System.out.println("Fortsätt (j/n): ");
- fortsätt = inmatning.next().charAt(0);
- }
- while(fortsätt == 'j');
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement