Write a program that simulates a simple calculator

Assignment Help JAVA Programming
Reference no: EM13764911

Question1:

1.1 Explain the difference between using a computer program and programming a computer.

1.2 How do you discover syntax errors? How do you discover logic errors?

1.3 What is the difference between object and object reference?

1.4 Explain the difference between an object and a class.

1.5 What is the difference between equality and assignment?

1.6 What is the difference between a reserved word and an identifier?

1.7 What is the implicit parameter? Explain with example.

1.8 Write a java statement to convert a string str to a double.

Question 2

2.1 Which of the following are legal identifiers? why?

Greeting1

g

void

104IT

IT104

Hello, World

Hello3World

2.2 Construct a logical expression to represent each of the following conditions:

a. x is between 3 and 15 but not equal to 10.

b. x is between 10 and 20 but not odd.

c. y is divisible by 5 but not by 40.

d. str is a lowercase or uppercase letter.

2.3 What is the difference between the following two statements?

a. if (n > 2) { if (n < 6) System.out.println("Done!"); }

else System.out.println("Error");

b. if (n > 2) { if (n < 6) System.out.println("Done!");

else System.out.println("Error"); }

2.4 What is the difference between the result of the following two statements?

a. int cents = (int)(100 * price + 0.5);

b. int cents = (100 * price + 0.5);

Question 3

3.1 Write an Algorithm to decide which is cheaper car or bus for a travel:

You want to decide whether you should drive your car to work or take the bus. You know the one-way distance from your home to your place of work, and the fuel efficiency of your car (in miles per gallon). You also know the one-way price of a train ticket. You assume the cost of gas at $4 per gallon, and car maintenance at 5 cents per mile. Write an algorithm to decide which commute is cheaper.

omplete the following program so that it to c only Use string concatenation3.2 prints the message "the quick white tiger jumps over the small dog". public class ConcatDemo { public static void main(String[] args) { String animal1 = "quick white tiger"; String animal2 = "small dog";

String article = "the"; String action = "jumps over"; /* Your work goes here */

System.out.println(message); } }

3.3 Find the output of the following code when the user enters 100 and when the user enters AQ:

public static void main(String[] args)

{

Scanner in = new Scanner(System.in);

System.out.print("Enter somthing: ");

String str = in.next();

int count = Integer.parseInt(str);

System.out.println("Input is " + count);

}

Question 4

4.1 Write a program that simulates a simple calculator. It reads two integers and a character. If the character is a +, the sum is printed; if it is a -, the difference is printed; if it is a *, the product is printed; if it is a /, the quotient is printed; and if it is a %, the remainder is printed.

4.2 In the 2- dimensional plane, a point is described by its two coordinates x and y. It supports these operations :

A constructor allowing initialization of both coordinates

Accessors and mutators to its coordinates

Translation of a point

a. Write a java class, called MyPoint, that corresponds to such an abstraction of points in the dimensional plane.

b. Provide a tester class that creates one point, then translates and displays its new coordinates.

Reference no: EM13764911

Questions Cloud

Network administrator : Using the library, the Internet, and any other materials, prepare a PowerPoint presentation that outlines the following items
Case- schneider v eady : Donna Driver gets into a car accident with Vic Victim in Cleveland, Ohio. Vic sustains severe injuries. Shaeffer, Whiting v. Grange Mutual Casualty Company, 1981 Ohio App. LEXIS 14351 (Ohio Ct. App. 1981)
Explain the planning your qualitative research plan : Explain the planning your qualitative research plan. To assist you with this, consider working on the literature review for your qualitative research plan.
What is the difference between the result of statements : What is the difference between the result of the following two statements. int cents = (int)(100 * price + 0.5)
Write a program that simulates a simple calculator : Write a program that simulates a simple calculator. It reads two integers and a character. If the character is a +, the sum is printed; if it is a -, the difference is printed; if it is a *, the product is printed; if it is a /, the quotient is pr..
Issues of critical analysis on appendicitis : It must include: history, description,anatomy of the system involved effect,cause,sign and symptoms, diagnosis,complication,treatment and side effect of Appendicitis.
Implement a capital investment decision : Often when deciding to implement a capital investment decision, funding through acquiring debt must be obtained. Recently the credit market has been tight to non-existent.
Memo to chief draper that addresses the chiefs concerns : Based on the media-based research data matrix you created, select one of the research areas identified above and prepare a 5-6 page memo to Chief Draper that addresses the Chief's concerns
Laplace transform : Find the Laplace transform of sin(2t). From the table of Laplace transforms, the Laplace transform of sin(2t) is

Reviews

Write a Review

JAVA Programming Questions & Answers

  Implement a shopping cart class with user interface

project will be to implement a shopping cart class with user interface (UI) that contains main() in Net Beans. The UI class will be used to perform user input/output and to invoke the appropriate methods of shopping cart class. When your program star..

  Wite a java application that allows the user to read

write a java application that allows the user to read validate store display sort and search the account

  Implements the queue interface

Element from an ArrayList is slow because of all the shifting. For this question, you should modify the poll()method so that it runs in constant time - implementations as well as correct/fast implementations. In the former case, your functions may..

  Create a class that uses the genetricstack class

Create a new class named GenericStack that specifies a type variable that gives for generics - Use the peek method to return the first item and show that item, and use the size method to return the number of items again and show that value.

  Error conditions as compared to using exception handling

What are the advantages and disadvantages of testing for error conditions as compared to using exception handling when performing input or output?

  Write down a java program which prints out division by zero

write a java program that prints out division by zero and array out of bounds exceptions when a user attempts to find

  Create a two dimensional integer array in java

Create a two dimensional integer array in JAVA that produces the sum of rows and columns as selected by the user.

  Rationale for declaring an array of objects of the class

Explain the dimension of the array and why you chose that number of elements for the object array.Can you give the answer ASAP?

  Write a void function this passed three integers

1. Write a void function this passed three integers by reference. The function should rearrange the parameter values so that the first parameter will get the smallest value; the second parameter the middle value; and the third parameter the largest v..

  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.

  Simulate the transactions of a checking account

create a base class, called CBankAccount, and two additional classes (each derived from CBankAccount), called CSavingsAccount and CCheckingAccount.

  Write program that uses a class named rectangle

Write program that uses a class named Rectangle. The class has floating point attributes length and width. it has member functions that calculate the perimeter and area of the rectangle. It also has set and get functions for both length and width.

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