SophiaPretty

(5)

$14/per page/Negotiable

About SophiaPretty

Levels Tought:
Elementary,Middle School,High School,College,University,PHD

Expertise:
Accounting,Algebra See all
Accounting,Algebra,Applied Sciences,Architecture and Design,Art & Design,Biology,Business & Finance,Calculus,Chemistry,Communications,Computer Science,Economics,Engineering,English,Environmental science,Essay writing Hide all
Teaching Since: Jul 2017
Last Sign in: 304 Weeks Ago, 2 Days Ago
Questions Answered: 15833
Tutorials Posted: 15827

Education

  • MBA,PHD, Juris Doctor
    Strayer,Devery,Harvard University
    Mar-1995 - Mar-2002

Experience

  • Manager Planning
    WalMart
    Mar-2001 - Feb-2009

Category > Engineering Posted 15 Oct 2017 My Price 10.00

I'm trying to integrate a try, catch, and finally block into my code.

/************************Name: Seth MilneProgram name: MathOPDate:9/3/2017Purpose: This program takes input from the userin the form of floating point numbers.Once thesenumbers are entered, it will prompt the user for an operator, as a string.There are four operators used, "+, -,/,*".Depending upon which operatorchosen, decidesthen what operation is perform and the result from that function displays theoutput.This program demonstrates the use of constructors, creation of objects,variables, set/get methods, and inheritance.**************************/import java.util.Scanner;/* includes a class that permits use of user input inthe program */class MathOP/* first class which introduces variables first and second */{private double first;private double second;public MathOP (double a , double b )/* constructors where variables are input*/{this.first= a; /* objects created as a and b */this.second=b;}public double getFirst() /* method gets the value of the first object */{return first;}public void setFirst(double first)/* method sets the value of the firstobject */{this.first= first;}public double getSecond(){return second;}public void setSecond(double second){this.second = second;}public double Add()/* operation method */{return first+second;}public double Sub(){return first-second;}}class MathOP2 extends MathOP /* The first class is extended to include the newclass to introduce multiplication and division */{MathOP2(double a, double b){
Background image of page 1
super(a, b);}public double Mul(){return super.getFirst() * super.getSecond();/* super is used to return to thevalue obtain in the original class method */}public double Div(){return super.getFirst() / super.getSecond();}}class ExecuteMathOP { /* This class will execute based upon the defined classespreviously.It will then verify the inheritance feature of Java */public static void main(String[] args){Scanner in = new Scanner(System.in);while (true){System.out.print("Enter the First number >>"); /* user input */double first = Double.parseDouble(in.nextLine());System.out.print("Enter the Second number >>");double second = Double.parseDouble(in.nextLine());System.out.print("Enter operator >>");String symbol = in.nextLine(); /* this takes the operator entered to astring object */MathOP2 mathOP2=new MathOP2(first,second); /* new object created withoriginal class properties */if (symbol.equals("+")){System.out.println("The answer is " + mathOP2.Add()); /* performsmethods outlined in the first class */}else if (symbol.equals("/")){System.out.println("The answer is " + mathOP2.Div()); /* performsmethods outlined in the second class */}else if (symbol.equals("*")){System.out.println("The answer is " + mathOP2.Mul());}else{System.out.println("The answer is " + mathOP2.Sub());}System.out.print("Do you want to exit (Y/N)?"); /* user input */String option = in.nextLine();if (option.equals("Y")){System.out.println("Thanks for using our system");
Background image of page 2

Answers

(5)
Status NEW Posted 15 Oct 2017 09:10 AM My Price 10.00

-----------  ----------- H-----------ell-----------o S-----------ir/-----------Mad-----------am ----------- Th-----------ank----------- yo-----------u f-----------or -----------you-----------r i-----------nte-----------res-----------t a-----------nd -----------buy-----------ing----------- 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----------- be----------- qu-----------ick-----------ly

Not Rated(0)