A mini Calculator programmed in Java ...
This will do basic Calculations Like Sum, Abstract, Multiplication and Division
Get the code and try it!
CODE:
package com.company;
import java.util.Scanner;
public class newproject {
public static void main(String[] args) {
float add;
float sub;
float mul;
float div;
System.out.println("Which Opreation you want to do?\n Type(1) for (+)\n (2) for (-) \n(3) for (*) " +
"\n(4) for (%) ");
Scanner sc=new Scanner(System.in);
int enter=sc.nextInt();
if(enter==1){
System.out.println("You are Doing Addition");
System.out.println("enter First Number");
float addition=sc.nextFloat();
System.out.println("Enter Second number");
float second=sc.nextFloat();
System.out.println("your answer is ");
add=addition+second;
System.out.println(add);
}
if(enter==2){
System.out.println("You are doing Subtraction");
System.out.println("Enter first digit");
float subtraction=sc.nextFloat();
System.out.println("Enter second number");
float second=sc.nextFloat();
System.out.println("Your answer is");
sub=subtraction-second;
System.out.println(sub);
}
if(enter==3){
System.out.println("You are doing Multiplication" );
System.out.println("Enter first number");
float multiplication=sc.nextFloat();
System.out.println("enter second number");
float third=sc.nextFloat();
System.out.println("Your answer is :");
mul=multiplication*third;
System.out.println(mul);
}
if(enter==4){
System.out.println("You are doing Division");
System.out.println("Enter First number");
float division=sc.nextFloat();
System.out.println("Enter Second number");
float forth=sc.nextFloat();
div=division/forth;
System.out.println(div);
}
if(enter>=5){
System.out.println("Wrong Choice!");
}
}
}
0 Comments
If you want any type of script please massege me on
hamzaw4hla@gmail.com