## [answered] Assignment2 Due date: Thursday - November17th, 2016at 11:59

Please see the attachment for My question,,?

Thanks..

Assignment2 Due date: Thursday - November17th, 2016at 11:59 PM. Q1. Explain what each of the following two program segments computes:

1- int x = 2;

int y = x + x;

2- String s = &quot;2&quot;;

String t = s + s;( .5 point ) Q2. Write the following mathematical expressions in Java.( .5 point ) Q3. What errors does this class have? How would you fix them? Rewrite the correct version

of this class.

public class Square {

private double sideLength;

private double area;

publicSquare(double sideLength) {

sideLength = sideLength;

}

public double getArea() {

area = sideLength * sideLength; returnarea;

}

public static void main(string args){

Square sq = new Square(4.4);

System.out.print(&quot;This Area of the square is:\t +sq. getArea);

( .5 point ) Q4. What is the order of execution of operators in the following equation?

a=99*5+4%2/6+(18-4)*2( .5 point ) Q5. Write a program called CheckPassFail which read the mark from user and prints &quot;PASS&quot;

if the mark is more than or equal to 60; or prints &quot;FAIL&quot; otherwise.

( 1pont ) Q6. Write a program that that computes the maximum of two numbers. You need to follow

the following instructions:

1. Create a class called ?MaxProgram?.

1. The class MaxProgram has only one methodcalled ?maxValue? . This

methodtakestwointegernumbers as parameters. The methodreturns the maximum

of the twonumbers, elseitreturns -1, If bothnumbers are equal.

1. To test this class, createanother class called ?Tester?, with a main method.

In the main method, create an object of the ?MaxProgram? class.

2. From the createdobject, call the ?maxValue? method, and giveitanytwonumbers.

3. Print the returned maximum number.

( 1 point ) Q7. A company applies a discount based on the price of the order. If the order is over \$50,

the discount is 5%. If the order is over \$100, the discount is 10%. Otherwise, there is no

discount. Write a sequence of if statements to get the discounted price of the order. (1

Point)

Solution details:
STATUS
QUALITY
Approved

This question was answered on: Sep 18, 2020

Solution~0001005167.zip (25.37 KB)

This attachment is locked

We have a ready expert answer for this paper which you can use for in-depth understanding, research editing or paraphrasing. You can buy it or order for a fresh, original and plagiarism-free copy from our tutoring website www.aceyourhomework.com (Deadline assured. Flexible pricing. TurnItIn Report provided)

STATUS

QUALITY

Approved

Sep 18, 2020

EXPERT

Tutor