Essay Writer » Essay Blog » Essay Writing Services Cheap » Programming Homework Help

Programming Homework Help

Programming I Homework 4 Help

Part 4a:


Create a Java class named <YourName>4a so mine would be Carden4a.java


Create a main method for your class as usual, but for now just leave it empty.


Create a method for your class named
sortAscending, which takes three integer parameters and returns nothing. This method will sort those three integers in ascending order and print the result to the console. The signature of the method is as follows:
public static void sortAscending( int a, int b, int c )


You may test your method with calls from main, or you may leave main empty. Your method will be tested with inputs that produce known outputs.


Here are a few example runs:
—-jGRASP exec: java Carden4a
// Sending 76, 8, 33 from main
Ascending order is: 8 33 76
—-jGRASP: operation complete.
—-jGRASP exec: java Carden4a
// Sending 9, 221, 9 from main
Ascending order is: 9 9 221
—-jGRASP: operation complete.


Programming Homework Help Part 4b:


Create a Java class named <YourName>4b so mine would be Carden4b.java


Write the Java method canFormRightTriangle that determines if it’s three integer arguments a, b, and c can be the lengths of the sides of a right triangle. Three integers can be the lengths of the sides of a right triangle if and only if all three are positive and the square of the largest integer is equal to the sum of the squares of the other two integers.


For example:


If
a = 4, b = 5, and c = 3, then the method would return true since b2 = a2 + c2.

Create a main method and prompt the user for three integers, and send those three to the method. The signature of the method is as follows:


public static boolean canFormRightTriangle( int a, int b, int c )


Other examples:

The following calls should return true The following calls should return false
canFormRightTriangle( 3, 4, 5 ) CanFormRightTriangle( 3, -4, 5 )
canFormRightTriangle( 5, 3, 4 ) CanFormRightTriangle( 0, 0, 0 )
canFormRightTriangle( 6, 10, 8 ) CanFormRightTriangle( 5, 0, 5 )
CanFormRightTriangle( 12, 5, 13 ) canFormRightTriangle( 1, 2, 3 )

 

Understand the Role of CSS

Part 4c:


Create a Java class named <YourName>4c, so mine would be Carden4c.java


This program will be an expansion of the previous assignment. Your program will be a multiplication quiz game that continues to prompt the user until the correct answer is given.


Create a main method for your class, but for now just leave it empty.


Create a method named
randomNumber, which generates and returns a random integer between 1 and 10 (inclusive). This method should have the following signature: public static int randomNumber()


You may copy your code from the previous assignment if you wish.


Declare two integer variables in main, and store in each of them a random number by calling the
randomNumber method. Next store the product of those random numbers in a new variable named product.


Lastly, display the two numbers and ask the user for the answer and compare it to the product calculated above. Check the user’s answer to see if it matches. If the user’s answer is correct, display their answer with the text “i
s correct!”. Otherwise, display the text “is not correct. Please try again.”, and ask the user for a new answer. Continue prompting until the user answers correctly.


Below are a few sample runs:

—-jGRASP exec: java Carden4c
Welcome to the multiplication game!
What is 7 * 2?
15
15 is not correct. Please try
again.
What is 7 * 2?
13 13 is not correct. Please try again.
What is 7 * 2?
14
14 is correct!
—-jGRASP: operation complete.
—-jGRASP exec: java Carden4c
Welcome to the multiplication game!
What is 1 * 9?
9
9 is correct!
—-jGRASP: operation complete.


General Instructions:


No hard copies will be collected. Do not send your files through e-mail! You should submit your work on D2L by the due date. See the syllabus for late homework policy.


What to turn in:


There should be three .java files. Place these files into a zip file and name it
<YourName>HW4.zip, and submit the zip file to the Dropbox Homework 4 folder in D2L.
Helpful Links:
How to zip files in Mac OS
How to zip files in Windows

Role of CSS in web programming

Programming I Homework Help

Last Updated on July 23, 2020

Don`t copy text!
Scroll to Top