logo Hurry, Grab up to 30% discount on the entire course
Order Now logo

Ask This Question To Be Solved By Our ExpertsGet A+ Grade Solution Guaranteed

expert
Ishrat KhanAccounting
(/5)

644 Answers

Hire Me
expert
Muhammad AhmerComputer science
(5/5)

597 Answers

Hire Me
expert
Caden ButlerEngineering
(5/5)

810 Answers

Hire Me
expert
Sonia TakiaNursing
(5/5)

811 Answers

Hire Me
Java Programming
(5/5)

Create a file called A.java, and in this file, declare a class called A. This class should define only one method called main().

INSTRUCTIONS TO CANDIDATES
ANSWER ALL QUESTIONS

First Java Assignment

Please read the entire pdf before starting.

You must do this assignment individually and, unless otherwise specified, you must follow all the general instructions and regulations for assignments. Graders have the discretion to deduct up to 10% of the value of this assignment for deviations from the general instructions and regulations. These regulations are posted on the course website. Be sure to read them before starting.

Part 1: 0 points

Part 2, Question 1: 40 points

Part 2, Question 2: 20 points

Part 2, Question 3: 40 points

100 points total

Before starting on the assignment, you should download from the course website the file assignment1.zip. Inside this file will be 3 directories:

Question1:  Question1Testfile.txt

Question2 : This directory will contain the file TaxCalulator.java

Question3:  This  directory  will  contain  the  files  TypeQuestions.java  and  typeexpressions.txt

Each of these files will be used for different parts of the assignment.

It is very important that you follow the directions as closely as possible. The directions, while perhaps tedious, are designed to make it as easy as possible for the TAs to mark the assignments by letting them run your assignment through automated tests. While these tests will not determine your entire grade, it will speed up the process significantly, which will allow the TAs to provide better feedback and not waste time on administrative details. Plus, if the TA is in a good mood while he or she is grading, then that increases the chance of them giving out partial marks :)

 Part 1 (0 points): Warm-up

Do NOT submit this part, as it will not be graded. However, doing these exercises might help you to do the second part of the assignment, which will be graded. If you have difficulties with the questions of Part 1, then we suggest that you consult the TAs during their office hours; they can help you and work with you through the warm-up questions.

Warm-up Question 1    (0 points)

Create a file called HelloWorld.java, and in this file, declare a class called HelloWorld. This class should define only one method called main(). In the body of this method, use System.out.println() to display “Hello world!”. You can find such a class in the lecture slides; make sure you can compile and run it properly.

Warm-up Question 2    (0 points)

Create a file called A.java, and in this file, declare a class called A. This class should define only one method called main(). In the body of this method, use System.out.println() to display the following pattern:

  A

 AA

AAAAA

A A

A A

Warm-up   Question   3     (0 points) Consider the following 2-d matrix:

a b

c d

Write a Java program that first reads 4 doubles, representing a,b,c, and d from the keyboard. It then outputs to the screen the determinant of the matrix.

For a 2x2 matrix, the determinant is always equal to a ∗ d − b ∗ c

Warm-up   Question   4    (0 points)

Now consider the same question except on a 3x3 matrix:

a b c

d e f

g h i

Write a Java program that first reads 9 doubles, representing the 9 letters above from the keyboard. It then outputs to the screen the determinant of the matrix.

For a 3x3 matrix, the determinant is always equal to a ∗ (i ∗ e − f ∗ h) − b ∗ (d ∗ i − f ∗ g) + c ∗ (h ∗ d − e ∗ g) 

Part 2

The questions in this part of the assignment will be graded.

Question 1:  Cheating on your calculus assignment   (40 points)

The purpose of this question is to practice writing a full Java program from start to finish. You will practice reading and writing to and from the screen and keyboard, respectively.

The following code should be put into a class Calculus and thus a file Calculus.java

Your friend is taking calculus and is having a hard time taking derivatives and integrals. Unfortunately (s)he has an assignment due tomorrow that forces him to take hundreds of derivatives and integrals. You, as a new computer science student, realize that you can help by providing a computer program that will calculate derivatives and integrals.

Write a Java program that does the following:

1. Display a prompt and ask the user to enter his or her name.

2. Display a prompt and ask the user to enter three integers, called a,b,c respectively. These numbers will represent the coefficients of a quadratic equation:

ax2 + bx + c

3. Print the formula they have entered on the screen.

4. Next print to the screen the derivative of the equation as a formula. For a quadratic equation above, the derivative will be

2ax + b

Your output should fill in the actual values for a and b and perform any necessary multuplications.

5. Next ask the user to enter a value for x. x can be any number ,not just an integer, so you should choose an appropriate type for the variable.

6. Print to the screen the result of 2ax + b

7. Next, print to the screen the formula for the antiderivative of the function. If the original function is ax2 + bx + c then the antiderivative will be:

a  x3 +  b 

x2 + cx 

3.0 2.0

Once again, your output should not include the letter a, b, or c. If you see what appears to be odd division results, try entering 3.0 instead of just 3 and 2.0 instead of just 2. This is a concept known as integer division in Java and will be covered later in the course.

8. Finally, print a message with your name followed by the name of your friend which was entered in the first step. This message should say that your friend permanently owes you for helping them out.

A sample run of this program should look as follows:

richter:~$ java Calculus Please enter your name Jorg

Now enter 3 numbers 4

The formula you have entered is:

4x^2 +  5x  +  6

The derivative of the equation is 8x+5

Enter a value  for  x 4

The derivative at the above point is:

37.0

The anti-derivative of the equation is 1.3333333333333333x^3 + 2.5x^2 + 6x

Jorg, you owe Dan Pomerantz forever!

Your program must adhere to this. You must verify this output by doing the following:

1. Find the file Question1TestFile.txt from the downloaded zip and move it to the same folder as the Calculus.class file. (This will normally be the same folder as the Calculus.java file.)

2. From the command prompt, navigate to the directory of your Java program and type

java Calculus < Question1TestFile.txt

Except for your name, the output should be identical (with the exception of the number of decimal points or a rounding error) to the above code.

Correction: Depending on your operating system the test file may not “echo” the input. For example the output when running on the test file may not include the name “Jorg” or the numbers 4, 5, and 6. This is fine as well. Your program may look like the following instead:

richter:~$ java Calculus < Question1TestFile.txt Please enter your name

Now enter 3 numbers

The formula you have entered is:

4x^2 +  5x  +  6

The derivative of the equation is 8x+5

Enter a value  for  x 4

The derivative at the above point is:

37.0

The anti-derivative of the equation is 1.3333333333333333x^3 + 2.5x^2 + 6x

Jorg, you owe Dan Pomerantz forever!

Question 2:  Tax Calculator   (20 points)

The purpose of this question is to give you a quick sample of how Java could be used to create a real-world, if small application. It will also give you practice with looking at code that someone else has written and see how one piece can contribute to the entire puzzle.

In this question, you will modify an existing program by adding to it.

Inside the directory for assignment one, you will find a file TaxCalculator.java You can compile and run this program as any other program by typing javac TaxCalculator.java followed by java TaxCalculator . Note that since this program uses graphics it may be difficult although not impossible to run via telnet or ssh. When you do this, you will see a small window pop-up with several textfields. You can type numbers into the 3 white ones, but not into the 3 gray ones.

(5/5)
Attachments:

Related Questions

. The fundamental operations of create, read, update, and delete (CRUD) in either Python or Java

CS 340 Milestone One Guidelines and Rubric  Overview: For this assignment, you will implement the fundamental operations of create, read, update,

. Develop a program to emulate a purchase transaction at a retail store. This  program will have two classes, a LineItem class and a Transaction class

Retail Transaction Programming Project  Project Requirements:  Develop a program to emulate a purchase transaction at a retail store. This

. The following program contains five errors. Identify the errors and fix them

7COM1028   Secure Systems Programming   Referral Coursework: Secure

. Accepts the following from a user: Item Name Item Quantity Item Price Allows the user to create a file to store the sales receipt contents

Create a GUI program that:Accepts the following from a user:Item NameItem QuantityItem PriceAllows the user to create a file to store the sales receip

. The final project will encompass developing a web service using a software stack and implementing an industry-standard interface. Regardless of whether you choose to pursue application development goals as a pure developer or as a software engineer

CS 340 Final Project Guidelines and Rubric  Overview The final project will encompass developing a web service using a software stack and impleme