0% found this document useful (0 votes)
4 views

Javacode

Java Code in programming
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

Javacode

Java Code in programming
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 3

import java.util.

*;

class Meliza {

double A,B;

Meliza (double A,double B){ this.A=A;

this.B=B;

double add () { return A+B;}

double sub() {return A-B;}

double multip(){return A*B;}

double divide(){return A/B;}

public class Main

public static void main(String[] args)

Scanner Mel=new Scanner(System.in);

System.out.println("Enter First Number: ");

double A=Mel.nextDouble();

System.out.print("Enter Second Number");

double B= Mel.nextDouble();

System.out.println("Enter Operation");
while (true) { System.out.println("*×*×*×*×*×*×*×*×*×*×*×*");

System.out.println("*×*×*×*×calculator*×*×*×*");

System.out.println("1. Add");

System.out.println(" 2. Subtract ");

System.out.println(" 3. Multiply");

System.out.println(" 4. Divide");

System.out.println(" 5. Exit");

System.out.println("Choose operation from 1-5");

int op= Mel.nextInt();

double c=0;

Meliza Cabasal= new Meliza (A,B);

switch(op){

case 1: c= Cabasal.add();

break;

case 2: c = Cabasal.sub();

break;

case 3 : c = Cabasal.multip();

break;

case 4: c= Cabasal.divide();

break;

case 5:

System.exit(0);
break;

default: System.out.println("Invalid operation");

System.out.println("="+c);

You might also like