The world’s Largest Sharp Brain Virtual Experts Marketplace Just a click Away
Levels Tought:
Elementary,Middle School,High School,College,University,PHD
| Teaching Since: | May 2017 |
| Last Sign in: | 398 Weeks Ago, 4 Days Ago |
| Questions Answered: | 66690 |
| Tutorials Posted: | 66688 |
MCS,PHD
Argosy University/ Phoniex University/
Nov-2005 - Oct-2011
Professor
Phoniex University
Oct-2001 - Nov-2016
QUESTION / SOALAN 3 Marks/Markah Consider the following Java program which uses the object of the class Calculator: import java.io.*; class uji{ public static void main (String[] args) throws IOException{ Pembaca baca = new Pembaca(); Calculator cl = new Calculator(); System.out.println(“Simple Calculator Program”); System.out.println(“Key in the first number >>”); int no1=baca.bacaInt(); System.out.println(“Key in the second number >>”); int no2=baca.bacaInt(); System.out.println(“The operation (+, -, *, / ) >>”); char input=baca.bacaChar (); if (input==’+’) System.out.print(“The result is ”+ cl.add(no1,no2)); else if (input==’-’) System.out.print(“The result is ”+ cl.substract(no1,no2)); else if (input==’*’) System.out.print(“The result is ”+ cl.multiply(no1,no2)); else if (input==’/’) System.out.print(“The result is ”+ cl.divide(no1,no2)); } } The above program will produce the following output: Simple Calculator Program Key in the first number >> 8 CBOP3203JAN09/F-SA 12 Key in the second number >> 34 The operation (+, -, *, / ) >> + The result is 46.0 Write the complete class definition for the class Calculator. (Total / Jumlah : 20)
Hel-----------lo -----------Sir-----------/Ma-----------dam----------- -----------Th-----------ank----------- Yo-----------u f-----------or -----------usi-----------ng -----------our----------- we-----------bsi-----------te -----------and----------- ac-----------qui-----------sit-----------ion----------- of----------- my----------- po-----------ste-----------d s-----------olu-----------tio-----------n. -----------Ple-----------ase----------- pi-----------ng -----------me -----------on -----------cha-----------t I----------- am----------- on-----------lin-----------e o-----------r i-----------nbo-----------x m-----------e a----------- me-----------ssa-----------ge -----------I w-----------ill-----------