Java Saved Program: peaceful-dog

facebook share

Here's the online compiler accompanied with IDE at your service. This is a saved code by one of our users. Try it out or save your own from the IDE page and don't forget to leave a feedback. You can find that at the bottom of the page.


import java.util.*;
import java.lang.*;
import java.io.*;
import java.util.Scanner;

/* Name of the class has to be "Script" only */
class Script
{
	public static void main (String[] args)
	{
	     
   
   Scanner s = new Scanner(System.in);
  
  
   System.out.println("Upisite dva realna broja");
   
   
   double x1, x2;
   x1 = s.nextDouble();
   x2 = s.nextDouble();
   
    System.out.println("Prvi broj:" +x1+ " ");
    System.out.println("Drugi broj:" +x2+ " ");
  
  
   System.out.println("Odabrati operaciju(broj):" +/n+ "1.Zbrajanje" +/n+ "2.Oduzmanje" +/n+ "3.Mnozenje" +/n+ "4.Dijeljenje");
   
   int a;
   a = s.nextInt();
   
   System.out.println("Odabrali ste:" +a+ " ");
   
    
   switch (a)
   {
     case 1:System.out.println("x1+x2=" + (x1+x2));break;
     
     case 2:System.out.println("x1-x2=" + (x1-x2));break;
    
     case 3:System.out.println("x1*x2=" + (x1*x2));break;
     
     case 4:System.out.println("x1/x2=" + (x1/x2));break;
     
    
     }
    

	} 
   }
  
Execute

Output

Press the execute button or CTRL + enter to run code.

Inputs