it has more info and examples Instructions: Java files will be compiled and tested using the following syntax on a Windows desktop: javac Problem1.

I can send you the attachment as well… it has more info and examples

Instructions:

Java files will be compiled and tested using the following syntax on a Windows desktop:

javac Problem1.java

java Problem1

All java files must compile using the command line and using java version 1.8.0_151

Each java file submitted is to include commented code as well as your name, course number

and date.

All java source files should be submitted in a zip package. For Homework 2, you will submit one

file called homework2.zip to d2l. The file homework2.zip should contain the following files:

Problem1.java

Problem2.java

Problem2.java

Problem4.java

Problems will be graded on the following:

● Commenting of code including but not limited to variables, classes

● Functions correctly based on tested use cases

● Neatly formatted code and conciseness.

Programs that do not compile will not receive credit.

Problem 1 (20 points)

Write class that contains the following two methods:

/** Convert from Celsius to Fahrenheit */

public static double celsiusToFahrenheit(double celsius)

/** Convert from Fahrenheit to Celsius */

public static double fahrenheitToCelsius(double fahrenheit)

The formula for the conversion is:

fahrenheit = (9.0 / 5) * celsius + 32

celsius = (5.0 / 9) * (fahrenheit – 32)

ICS 141 – Spring 2018

Homework 2

Due 2/27/17

Chapters 6-8

80 points

The user should be asked for two command line input arguments, the first being either C or F for

celsius and fahrenheit and the next for the temperature. The program should then output the

appropriate conversion. Here is a sample command line output of the program:

Problem 2 (20 points)

Credit card numbers follow certain patterns. A credit card number must have between 13

and 16 digits. It must start with:

4 for Visa cards

5 for Master cards

37 for American Express cards

6 for Discover cards

In 1954, Hans Luhn of IBM proposed an algorithm for validating credit card numbers.

The algorithm is useful to determine if a card number is entered correctly or if a credit

card is scanned correctly by a scanner. Almost all credit card numbers are generated

following this validity check, commonly known as the Luhn check or the Mod 10 check,

which can be described as follows (for illustration, consider the card number

ICS 141 – Spring 2018

Homework 2

Due 2/27/17

Chapters 6-8

80 points

4388576018402626):

Step 1) Double every second digit from right to left. If doubling of a digit results in a two-digit

number, add up the two digits to get a single-digit number.

2 * 2 = 4

2 * 2 = 4

4 * 2 = 8

1 * 2 = 2

6 * 2 = 12 (1 + 2 = 3)

5 * 2 = 10 (1 + 0 = 1)

8 * 2 = 16 (1 + 6 = 7)

4 * 2 = 8

Step 2) Now add all single-digit numbers from Step 1.

4 + 4 + 8 + 2 + 3 + 1 + 7 + 8 = 37

Step 3) Add all digits in the odd places from right to left in the card number.

6 + 6 + 0 + 8 + 0 + 7 + 8 + 3 = 38

Step 4) Sum the results from Step 2 and Step 3.

37 + 38 = 75

Step 5) If the result from Step 4 is divisible by 10 and the card starts with an acceptable digit,

the card number is valid. Otherwise, it is invalid..

Write program that prompts the user to enter a credit card number as a long integer.

Display whether the number is valid or invalid.

Here are sample runs of the program:

ICS 141 – Spring 2018

Homework 2

Due 2/27/17

Chapters 6-8

80 points

Problem 3 (20 points)

A school has 100 lockers and 100 students. All lockers are closed on the first day of

school. As the students enter, the first student, denoted S1, opens every locker. Then the

second student, S2, begins with the second locker, denoted L2, and closes every other

locker. Student S3 begins with the third locker and changes every third locker (closes it if

it was open, and opens it if it was closed). Student S4 begins with locker L4 and changes

every fourth locker. Student S5 starts with L5 and changes every fifth locker, and so on,

until student S100 changes L100.

After all the students have passed through the building and changed the lockers, which

lockers are open?

Write program to find your answer.

(Hint: Use an array of 100 boolean elements, each of which indicates whether a locker is

open (true) or closed (false). Initially, all lockers are closed.)

Here is a sample run of the program with some of the lockers partially blurred out:

ICS 141 – Spring 2018

Problem 4 (20 points)

Write the following function that tests whether a two-dimensional list has four consecutive

numbers of the same value, either horizontally, vertically, or diagonally.

public static boolean isConsecutiveFour(int[][] values)

Write test program that prompts the user to enter a 6×6 matrix consisting of numbers 0-9. The

program displays true if the list contains four consecutive numbers with the same value.

Otherwise, the program displays false.

Here are some sample runs of the program:

7s diagonally

ICS 141 – Spring 2018

Homework 2

Due 2/27/17

Chapters 6-8

80 points

2s horizontally

0s vertically

No 4 in a row found

Calculate the price of your order

550 words
We'll send you the first draft for approval by September 11, 2018 at 10:52 AM
Total price:
$26
The price is based on these factors:
Academic level
Number of pages
Urgency
Basic features
  • Free title page and bibliography
  • Unlimited revisions
  • Plagiarism-free guarantee
  • Money-back guarantee
  • 24/7 support
On-demand options
  • Writer’s samples
  • Part-by-part delivery
  • Overnight delivery
  • Copies of used sources
  • Expert Proofreading
Paper format
  • 275 words per page
  • 12 pt Arial/Times New Roman
  • Double line spacing
  • Any citation style (APA, MLA, Chicago/Turabian, Harvard)

Our guarantees

Delivering a high-quality product at a reasonable price is not enough anymore.
That’s why we have developed 5 beneficial guarantees that will make your experience with our service enjoyable, easy, and safe.

Money-back guarantee

You have to be 100% sure of the quality of your product to give a money-back guarantee. This describes us perfectly. Make sure that this guarantee is totally transparent.

Read more

Zero-plagiarism guarantee

Each paper is composed from scratch, according to your instructions. It is then checked by our plagiarism-detection software. There is no gap where plagiarism could squeeze in.

Read more

Free-revision policy

Thanks to our free revisions, there is no way for you to be unsatisfied. We will work on your paper until you are completely happy with the result.

Read more

Privacy policy

Your email is safe, as we store it according to international data protection rules. Your bank details are secure, as we use only reliable payment systems.

Read more

Fair-cooperation guarantee

By sending us your money, you buy the service we provide. Check out our terms and conditions if you prefer business talks to be laid out in official language.

Read more