Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This assignment was locked May 2 at 1 1 : 5 9 pm . getLargestDigit ( ) ( ) Method ( see tests in TwoMethodsA

This assignment was locked May 2 at 11:59pm.
getLargestDigit()() Method (see tests in TwoMethodsA03.zip Download TwoMethodsA03.zip )
15 pts.
fractionSum() Method (see tests in TwoMethodsA03.zip Download TwoMethodsA03.zip)
15 pts.
Greatest and Least of These
20 pts.
Random Numbers in File
24 pts.
Code commented thoroughly
All requirements met
25 pts.
Code compiles
1 pts.
TOTAL: 100 pts.
Submissions
This assignment requires you to submit three Java source code files with these exact names:
TwoMethodsA03.java
GreatestAndLeast.java
RandomsInFile.java
General Requirements
All files you are turning in must be signed. Please add your name to the source code in comments.
Add comments to the source code you are writing:
Use Descriptive variable names. Otherwise, Describe the purpose of every variable
Explain the algorithm you are using for solution
Any methods except for main() must have a Java Doc comment.
Uncommented work loses up to 10 points.
Turn in only the source code all files with .java extension. Make sure the source code files named correctly.
Two Methods getLargestDigit() method
Write a method that takes an integer number (either positive or negative), and finds and returns the largest digit in that number.
Requirements:
Do not use arrays in your solution.
Do not convert integer into a string in order to extract digits. Use % operator instead.
Start coding with TwoMethodsA03.zip Download TwoMethodsA03.zip
Make sure to write method code according to the specifications and test them using unit tests provided in TwoMethodsA03.zip Download TwoMethodsA03.zip
Do not add any imports to the project - all packages needed for solution are already imported.
Do not alter any of the tests. If your code is not passing a test, find and fix errors in your method implementation rather than changing the test code.
No partial credit will be given for a method that fails even one test.
Two Methods fractionSum() method
Write a method that calculates and returns sum of fractions 1/2+2/3+...+ n/(n+1) where value n is passed as parameter and defines the length of the pattern and the sum. The method returns -1 if the value of n is less than 1.
Examples:
fractionSum(1)=1/2
fractionSum(2)=1/2+2/3
fractionSum(3)=1/2+2/3+3/4
fractionSum(5)=1/2+2/3+3/4+4/5+5/6
fractionSum(0)=-1
Start coding with TwoMethodsA03.zip Download TwoMethodsA03.zip
Make sure to write method code according to the specifications and test them using unit tests provided in TwoMethodsA03.zip Download TwoMethodsA03.zip
Do not add any imports to the project - all packages needed for solution are already imported.
Do not alter any of the tests. If your code is not passing a test, find and fix errors in your method implementation rather than changing the test code.
No partial credit will be given for a method that fails even one test.
The Greatest and the Least of These
Write a program with a loop that lets the user enter a series of positive integers. The user should enter -99 to signal the end of the series. Any negative number other than -99 must be rejected with a message ERROR: no negative values other than -99 accepted!. After all the numbers have been entered, the program should display the largest and the smallest numbers entered. If no numbers were entered (user entered -99 right away) a message No numbers were entered must appear.
Name your solution project GreatestAndLeast.java.
Use The greatest of a set of numbers algorithm (see below) to solve the problem.
Requirements:
Your code must run correctly on the test cases provided below.
DO NOT use arrays or ArrayLists to store the numbers in the series. Numbers must be analyzed on the spot and discarded.
Error message in response to negative value other than -99 must include word ERROR to pass the CodeGrade tests.
No numbers were entered must appear when no numbers were entered.
When user entered at least one integer other than -99 the report must list first the largest number, with the word largest preceding it, and then the smallest number, with the word smallest preceding it. See sample user interaction for more details. These details are important to pass the CodeGrade tests.
The greatest of a set of numbers algorithm:
Get (input) the first number, set it to be the greatest one for now.
Get the next number.
If the new number is bigger than the greatest one set the new one to be the greatest.
Repeat steps 2-4 until all the numbers are consumed.
Test cases
User input (1 number): -99
Produces output No numbers were entered
Input 2 numbers: 1,-99
Output: the largest number: 1 ; the smallest number: 1
Input 5 numbers :1,2,55,0,-99
Output: the largest number: 55 ; the smallest number: 0
Name your solution project GreatestAndLeast.java.
User interaction sample #1
Enter a positive integer

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions