# EECS 1510 Project 5 – Methods, Arrays, and Strings

\$30.00

Category: You will Instantly receive a download link for .zip solution file upon Payment

## Description

5/5 - (7 votes)

Program 1 (40 points) BinaryConversion.java
Consider the following dialog:
Enter a binary number: 1110
Conversion to decimal: 14
Enter a binary number: 10010000
Conversion to decimal: 144
Enter a binary number: ­1
All set !
Write the application implied above. In particular, the program will read a sequence of binary
strings and convert each one to a decimal integer. The program will terminate when the string -1 is
given. You must do the conversion by hand, and NOT use the predefined functions in Java for the
wrapper class Integer.
You must use a function for the conversion to decimal, where the parameter to the function is the
binary string, and the return value is the equivalent decimal integer.
public static int binaryToDecimal (String binaryString)
Program 2 (30 points) Valid Phone Numbers
Phone number can have one of several valid formats: In particular, strings like
419-460-1212 (419)460-1212 460-1212
are valid but strings like
419-460 (419)460-a321 46012-12
are not. Write a program to read in a string and check whether it has the format
ddd-ddd-dddd
where each d is a digit.
Program 3 (90 points) FastestRunner.java A group of 16 students decided to run in
the Columbus Marathon. Their names and times (in minutes) are below:
Name Time (minutes)
Elena 341
Thomas 273
Hamilton 278
Suzie 329
Phil 445
Matt 402
Alex 388
Emma 275
John 243
James 334
Jane 412
Emily 393
Daniel 299
Neda 343
Aaron 317
Kate 265
Find the fastest and the second fastest runner.
In particular, write a program as follows.Print the list of runners and times as above. Then print the
name of the fastest runner and his/her time (in hours and minutes). Also, find the second fastest
runner. Print the name and his/her time (in hours and minutes).
The program should have a method that takes as input an array of integers and returns the index
corresponding to the person with the lowest time. The program should apply this method to the
array of running times to find the fastest runner.
Also include a second method to find the second-best runner. The second method should use the
first method to determine the best runner, and then returns the index corresponding to the person
with the second lowest time.
Extra Credit (10 points): Print the list of runners and times nicely formatted in columns as
displayed above. One option is to use the printf() method.
Here is some program code to get started:
class Marathon {
public static void main (String[] arguments){
final int numRunners = 16;
String[] names ={“Elena”, “Thomas”, “Hamilton”, “Suzie”, “Phil”, “Matt”,
“Alex”, “Emma”, “John”, “James”, “Jane”, “Emily”, “Daniel”,
“Neda”,”Aaron”, “Kate”};
int[] times ={341, 273, 278, 329, 445, 402, 388, 275, 243, 334, 412,
393, 299,343, 317, 265};
. . .
for (int i = 0; i < numRunners; i++) {
System.out.println(names[i]+ “: ” + times[i]);
}
. . .