Starting from:

$29.99

Assignment 1 Manipulating integer and doubles

COMP 248 
Assignment 1

Purpose: The purpose of this assignment is to help you learn Java
identifiers, assignments, input/output and if and if/else
statements.
CEAB/CIPS Attributes: Design/Problem analysis/Communication Skills
General Guidelines When Writing Programs
Include the following comments at the top of your source codes
// -------------------------------------------------------
// Assignment (include number)
// Written by: (include your name and student id)
// For COMP 248 Section (your section) – Winter 2020
// --------------------------------------------------------
 In a comment, give a general explanation of what your program does. As the programming
questions get more complex, the explanations will get lengthier.
 Include comments in your program describing the main steps in your program. Focus of
your comments should be on the what rather than the how.
 Display a welcome message.
 Display clear prompts for users when you are expecting the user to enter data from the
keyboard.
 All output should be displayed with clear messages and in an easy to read format.
 End your program with a closing message so that the user knows that the program has
terminated.
Questions
Question 1 - Manipulating integer and doubles (6 pts)
Write a program that reads the numerators and denominators of
two fractions into 4 variables of type integer. You can assume
that the user will enter non-zero denominators. Your program
then outputs the product and the sum of the two fractions as a
fraction and as a percentage.
Figure 1:
https://www.youtube.com/watch?v=zQu
UNE50JnM
COMP248/Winter 2020 - Assignment 1 Page 2 of 4
Hint: Multiplying an integer by 1.0 converts it to a real number (a number with a decimal), or
storing an integer value into a double variable convert it to a real number as well.
Following is a sample output screen. Data entered by the user is in green. Your program should
work for any numbers entered, not just the ones in the sample below.
Figure 2. Sample output screen for Question 1
Note: Your program must display the same information but can be formatted differently.
Question 2 – Manipulating variables of type String (6 points)
Write a program which
1. Display a welcome message.
2. Prompts the user for his/her favorite city which it then stores in
a variable of type String.
3. Store the number of letters in the city name in a variable of type
int.
4. Display the city name as it was entered by the user and the
number of letters in it.
5. Display the city name all in upper case.
6. Display the city name with the second letter in upper-case.
7. Display the city name with the second to last letter in upper-case.
8. Display the city name with the middle letter in upper-case. Note: The middle letter
is the letter at location length() of the word divided by 2.
9. Display a farewell message, so that the user knows that the program has terminated
normally.
Figure 3 -
https://www.colourbox.c
om/vector/cartoon-citybackground-vector10206816
COMP248/Winter 2020 - Assignment 1 Page 3 of 4
Restrictions: No looping statements allowed (or needed). This questions requires the use of the
String functions length(), substring() and toUpperCase().
Following is a sample output screen. Data entered by the user is in green. Youbelowr program
should work for any one-word city name entered not just the one in the sample output.
Figure 4. Sample output screen for Question 2
Note: Your program must display the same information but can be formatted differently.
Submitting Assignment 1
What to submit:
Zip the 2 source codes (the .java files only please, not the entire project) of this assignment
as a .ZIP file (NOT .RAR) using the following naming convention:
a#_studentID, where # is the number of the assignment and studentID is your
student ID number.
For example, for the first assignment, student 123456 would submit a zip file named
a1_123456.zip
How to submit:
For sections U & W, please check your Moodle course webpage and for section EC please
check your eConcordia webpage for instructions on how to submit your assignment.
COMP248/Winter 2020 - Assignment 1 Page 4 of 4
Evaluation Criteria for Assignment 1 (20 points)
Source Code
Comments for all 3 questions (5 pts.)
 Description of the program (authors, date, purpose) 2 pts.
 Description of variables and constants 1 pt.
 Description of the algorithm 2 pts.
Programming Style for all 3 questions (3 pts.)
 Use of significant names for identifiers 1 pt.
 Indentation and readability 1 pt.
 Welcome Banner or message/Closing message 1 pt.
Question 1 (6 pts.)
 Input numerator/denominators 1 pt.
 Calculate product 1.5 pts.
 Calculate sum 1.5 pts.
 Display results in requested format 2 pts.
Question 2 (6 pts.)
 Input city name 1 pt.
Echo input with length 1 pt.
 Display with all letters in upper case 1 pt.
 Display with 2
nd letter in upper case 1 pt.
 Display with 2
nd to last letter in upper case 1 pt.
 Display with middle letter in upper case 1 pt.
TOTAL 20 pts.

More products