السلام عليكم ورحمة الله وبركاته
اخواني واخواتي ممكن حد يساعدني في حل هالبرنامج والسؤال هو:
simulate a calculator.
Ask the user, till pressing C, to enter the first number, the second number and do the operation.Use Escape Sequences
وكان حلي بهالطريقه بس ما عرفت كيف اوصل للحل الصحيح اتمنى المساعده
public class Calclator1{
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
int x,y;
int z;
float c,op=0;
//Create Scanner to obtain input from command window(console)
// Scanner s=new Scanner();
Scanner s=new Scanner(System.in);
System.out.print("Enter first ");
x=s.nextInt();
// Scanner op=new Scanner();
Scanner op1=new Scanner(System.in);
System.out.print("c ");
System.out.print(" second number ");
y=s.nextInt();
if (op=='+')
{
z=x+y;
System.out.println("The summation is"+z);
}
else
if(op=='-')
{
z=x-y;
System.out.println("The subtraction is"+z);
}
else
if(op=='/')
{
z=x/y;
System.out.printf("The division is"+z);
}
else
if(op=='*')
{
z=x*y;
System.out.println("The multiplication is"+z);
}
}
}
import java.util.Scanner;
ولكم جزيل الشكر