What is the order of execution of operators

Assignment Help JAVA Programming
Reference no: EM131598107

Assignment

Q1. Explain what each of the two program segments computes:

1- int x = 2;
int y = x + x;

2- String s = "2";
String t = s + s;

Q2. Write the following mathematical expressions in Java.

dm = m (√(1+ v/c)/√(1 - v/c) - 1)   Volume = 4Πr2/3

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;
area = sideLength * sideLength;
}
public double getArea() {
returnarea;
}
public static void main(string[] args){
Square sq = new Square(4.4);
System.out.print("This Area of the square is:\t +sq. getArea);

Q4. What is the order of execution of operators in the following equation?

a=99*5+4%2/6+(18-4)*2

Q5. Write a program called CheckPassFail which read the mark from user and prints "PASS" if the mark is more than or equal to 60; or prints "FAIL" otherwise.

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'.
2. 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.

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.

Reference no: EM131598107

Questions Cloud

Discussion on long term effects of families of individuals : Discussion on Long Term Effects of Families of Individuals Who Were Wrongfully Incarcerated Compared to Families of Individuals Who Committed a Crime.
Best constitution in the world : The US Constitution is head and shoulders the best constitution in the world. Therefore, what should we do about global commerce and the global economy?
Address the concept of citizen involvement : Locate at least three articles from peer-reviewed sources that address the concept of citizen involvement. You will use these articles in your discussion.
Discuss each of the three social classes including roles : Discuss and compare each of the three social classes including roles, expectations, and a comparison of the living situations.
What is the order of execution of operators : What errors does this class have? How would you fix them? Rewrite the correct version of this class - Explain what each of the two program segments computes
Aggregate-demand curve slopes downward : Consider listing and explaining the three reasons the aggregate-demand curve slopes downward.
Determine the price of the good or the quantity supplied : Does the monopoly determine the price of the good or the quantity supplied?
Break-even analysis : A company's fixed operating costs are $500,000, what unit sales volume will its income equal its costs?
Create a case history for a person with an addiction : Create a case history for a person with an addiction and a mental disorder. Do not include identifying information.

Reviews

Write a Review

JAVA Programming Questions & Answers

  What is wrong with the given syntax

What is wrong with the following syntax? One of the three steps necessary to create a rolling banner is to create an __________ object. The __________ HTML tag is a form element used to define a selection list.

  Design an object hierarchy

Design an object hierarchy and design your own UML class diagram to reflect the classes and relationship required by your program.

  Create an array to hold four account objects

Write Mybank class in Mybank.java. Create an array to hold four Account objects. For each account, randomly set the balance in the range of $0-$1000.00; print out the balance of each account

  Create a web application for sheridan restaurant

Create a web application for Sheridan Restaurant Reviews that contains the following functionality - Display a table of all restaurants based on the city entered by the user

  Explain the process of initializing an object

Which method is invoked in a particular class when a method definition is overridden in several classes that are part of an inheritance hierarchy

  Develop a java gui application using layout managers

Objectives- Develop a Java GUI application using layout managers, Develop an application that uses two or more classes and Read and/or write from/to text files

  Explain error and exception and how jsp handles them

Explain error and exception and how JSP handles them. Discuss in detail JSP Life cycle. Use diagram. Create a JSP program for Loan Calculator. It calculates both Simple and Compound interest.

  Calculate the average of the values in the integer array

Calculate the average of the values in the integer array, multiply that average by the weight, and return the result - The method calcWeightedAvg should return a double and take two parameters

  What the book refers to as conditional statements and loops

Create two files, one named third.html and the other named third.js What the book refers to as "Conditional Statements and Loops" is normally called flow control by programmers.

  How many variables can be held in the local variable array

One byte is used for the opcode, the other indicates the offset into the array. How many variables can be held in the local variable array? What do you think happens when this number is exceeded?

  Develp a simple model of an object-oriented system

you are going to develp a simple model of an object-oriented system. this model should be able to provide all the working examples of inheritance, encapsulation, and polymorphism through the use of class,. methods, and objects

  Prints out a summary for a list of prescriptions

Create a class that prints out a summary for a list of prescriptions. Using your Prescription class and some if statements you will read in 3 prescriptions and print out an appropriate summary with a list of the prescriptions

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd