Starting from:

$24.99

Comp248 Assignment 1 Solution

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)
//
• 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: Call Me a Calculator
You will communicate with the program to calculate the addition, subtraction, multiplication, division of two integers. Some more detailed requirements:
• Print the greeting information
• Prompt the user to enter two integers
• Calculate the addition, subtraction, multiplication, division of the two integers
• Display the calculation results
• Prompt the user the end of the program

Hints: i) be careful, the results of some of the operations are no more integers. Thus, you need to display the results properly. ii) the second operand cannot be 0. However, we do not require you to validate the inputs in this assignment, as we do not learn the control flow yet.

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.




Question 2: Chatbot

In this program, you learn how to operate with Strings. You are asked to display the input strings in different ways. The detailed requirements:
• Print the greeting information
• Prompt the user to enter his/her name
• Display the name in upper cases and display how many characters in the name
• Ask the user to enter a city name
• Display the city name in different ways: the middle letter in upper case, the second letter in upper case, and the second to the last letter in upper case.
• Prompt the user the end of the program



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 this second assignment, student 123456 would submit a zip file named a1_123456.zip How to submit:
Submit from moodle course page. If you are in an eConcordia course, please
check your eConcordia webpage for instructions on how to submit your assignment.

Evaluation Criteria for Assignment 1
Source Code
Comments for all 2 questions (3 pts.)
Description of variable and constants 1 pt.
Description of the algorithm 1 pt.
Programming styles for all 2 questions (3 pts.)
Use of significant names for identifiers 1 pt.
Indentation and readability 1 pt.
Welcome Banner/Closing message 1 pt.
Question 1 (6 pts.)
Input the integers 1 pt.
Calculate + 1 pt.
Calculate - 1 pt.
Calculate * 1 pt.
Calculate / 1 pt.
Display correct results 1 pt.
Question 2 (7 pts.)
Input user name 2 pts.
Echo input with length and proper format 2 pts.
Input city name 1 pt.
Display the middle letter in upper case 1 pt.
Display with 2nd letter in upper case 1 pt.
Display with 2nd to last letter in upper case 1 pt.
TOTAL 20 pts.

More products