Sale!

CSC1016S Assignment 1: Basic Syntax

$30.00 $18.00

Category: You will Instantly receive a download link for .zip solution file upon Payment || To Order Original Work Click Custom Order?

Description

5/5 - (6 votes)

Assignment Instructions
This assignment involves constructing structured programs in Java using class declarations, variable
declarations, if statements, for loops and while loops, import statements, and input and output
statements.
Exercise One [35 marks]
Write a program called TimeConvertor.java that converts times expressed in 24 hour clock to 12
hour clock and that converts times expressed in 12 hour clock to 24 hour clock. Here are five
examples of what the program should look like when it runs:
i.
Enter a time ([h]h:mm [am|pm]):
00:00
12:00 am
ii.
Enter a time ([h]h:mm [am|pm]):
12:00 am
00:00
iii.
Enter a time ([h]h:mm [am|pm]):
4:00 pm
16:00
iv.
Enter a time ([h]h:mm [am|pm]):
17:01
5:01 pm
v.
Enter a time ([h]h:mm [am|pm]):
5:11 am
05:11
HINT: Test to see whether the input ends with an ‘m’.
Exercise Two [30 marks]
Write a program called ImperialMetric.java that displays a conversion table for feet and inches to
metres. The program should ask the user to enter the range of values that the table will hold.
Here is an example of what should be output when the program runs:
Enter the minimum number of feet (not less than 0):
5
Enter the maximum number of feet (not more than 30):
9
| 0″ 1″ 2″ 3″ 4″ 5″ 6″ 7″ 8″ 9″ 10″ 11″
5′ | 1.524 1.549 1.575 1.600 1.626 1.651 1.676 1.702 1.727 1.753 1.778 1.803
6′ | 1.829 1.854 1.880 1.905 1.930 1.956 1.981 2.007 2.032 2.057 2.083 2.108
7′ | 2.134 2.159 2.184 2.210 2.235 2.261 2.286 2.311 2.337 2.362 2.388 2.413
8′ | 2.438 2.464 2.489 2.515 2.540 2.565 2.591 2.616 2.642 2.667 2.692 2.718
9′ | 2.743 2.769 2.794 2.819 2.845 2.870 2.896 2.921 2.946 2.972 2.997 3.023
The following web page provides advice on formatting numerical output:
https://docs.oracle.com/javase/tutorial/java/data/numberformat.htmlhttps://docs.oracle.com/java
se/tutorial/java/data/numberformat.html
CONTINUED
The sample solution used to generate the above example and the automarker scripts uses
System.out.printf() with a format string of “%6.3f” to print the metric values.
We recommend the following formula:
double metres = (feet*12+inches)*0.0254;
Exercise Three [35 marks]
Write a program called PalinPerfect.java that finds all palindrome perfect squares between two
integers supplied as input (start and end points are excluded).
 A palindrome number is a number that reads the same from the front and the back. For
example: 212, 44, 9009, 4567654
Hint: To calculate whether a number is a palindrome or not, you can first reverse the
number (using the % operator and a loop, or a String) and then check for equality.
 A perfect square is a number that is the square of an integer. For example: 1, 4, 9, 16, …
Hint: Use Math.sqrt to find the square root of a number.
Some examples of palindromic perfect squares are: 4, 121, 676.
Sample I/O:
Enter the starting point N:
200
Enter the ending point M:
678
The palindromic perfect squares are as follows:
484
676
Marking and Submission
Submit the TimeConvertor.java, ImperialMetric.java, and PalinPerfect.java files contained within a
single .ZIP folder to the automatic marker. The zipped folder should have the following naming
convention:
yourstudentnumber.zip
END