A simple calculator with do you want to continue in Java programming language.
I am currently accepting programming work, IT projects, school and application development, programming projects, thesis and capstone projects, IT consulting work, computer tutorials, and web development work kindly contact me at the following email address for further details. If you want to advertise on my website kindly contact me also in my email address also. Thank you.
My email address is the following jakerpomperada@gmail.com, jakerpomperada@aol.com, and jakerpomperada@yahoo.com.
My mobile number here in the Philippines is 09173084360.
Please subscribe to my channel https://www.youtube.com/channel/UCOs-lpOoIeJoh6gpJthPoGg
=================================================
Want to support my channel?
GCash Account
Jake Pomperada
09173084360
Paypal
https://paypal.me/jakerpomperada
Patreon
https://www.patreon.com/jakerpomperada
Thank you very much for your support.
Program Listing
package demo;
import java.util.Scanner;
public class mdas {
public static void main(String[] args) {
// create Scanner class object to
// read inputs
Scanner scan = new Scanner(System.in);
// Declare variables
int num1=0, num2=0;
char operator='\0';
char choice= '\0';
do {
System.out.print("Enter the first Number : ");
num1 = scan.nextInt();
System.out.print("Enter the the Second number : ");
num2 = scan.nextInt();
// read operator
System.out.println("Available Operators"
+ "are:: (+ - * /)");
System.out.print("Choose Oerator : ");
operator = scan.next().charAt(0);
if (operator == '+') {
System.out.println("The sum of "+ num1 + " and " + num2 + " is " + (num1+num2)+".");
} else if (operator == '-'){
System.out.println("The difference between "+ num1 + " and " + num2 + " is " + + (num1-num2)+".");
}
else if (operator == '*') {
System.out.println("The product between "+ num1 + " and " + num2 + " is " + + (num1*num2)+".");
}
else if (operator == '/') {
System.out.println("The quotient betwenn "+ num1 + " and " + num2 + " is " + + (num1/num2)+".");
}
else {
System.out.println("Invalid operator");
} // end of switch-case
System.out.print("Do you want to perform another calculation? [y-yes/n-no] : ");
choice = scan.next().charAt(0);
if (choice == 'N'|| choice == 'n') {
System.out.print("End of Program");
break;
}
} while(choice == 'Y'|| choice == 'y');
scan.close();
}
}
No comments:
Post a Comment