Let's Code Calculator in java | Codes for Mathematics | #code3
Char Input Video : • How to input char in java | #java
New video of this series on every Sunday :)
Code :-
import java.util.Scanner;
public class uz_03_claculator {
public static void main(String[] args) {
Scanner sc = new Scanner (System.in);
System.out.println("Enter 1st No.");
float num1 = sc.nextFloat();
System.out.println("Enter Sign.");
char sign = sc.next().charAt(0);
System.out.println("Enter 2nd No.");
float num2 = sc.nextFloat();
switch (sign) {
case '+' :
System.out.format("The addition of %f and %f ="+(num1+num2),num1,num2);
break;
case '-' :
System.out.format("The difference of %f and %f ="+(num1-num2),num1,num2);
break;
case '*' :
System.out.format("The product of %f and %f ="+(num1*num2),num1,num2);
break;
case '/' :
System.out.format("The quotient of %f and %f ="+(num1/num2),num1,num2);
break;
}
}
}
On this page of the site you can watch the video online Let's Code Calculator in java | Codes for Mathematics | with a duration of hours minute second in good quality, which was uploaded by the user Utkarsh's Zone 18 February 2023, share the link with friends and acquaintances, this video has already been watched 31 times on youtube and it was liked by 4 viewers. Enjoy your viewing!