College of Computing and InformaticsAssignment 1
Deadline: Sunday 01/01/2023 @ 23:59
[Total Mark for this Assignment is 8]
Student Details:
Name: ###
ID: ###
CRN: ###
Instructions:
• You must submit two separate copies (one Word file and one PDF file) using the Assignment Template on
Blackboard via the allocated folder. These files must not be in compressed format.
• It is your responsibility to check and make sure that you have uploaded both the correct files.
• Zero mark will be given if you try to bypass the SafeAssign (e.g. misspell words, remove spaces between
words, hide characters, use different character sets, convert text into image or languages other than English
or any kind of manipulation).
• Email submission will not be accepted.
• You are advised to make your work clear and well-presented. This includes filling your information on the cover
page.
• You must use this template, failing which will result in zero mark.
• You MUST show all your work, and text must not be converted into an image, unless specified otherwise by
the question.
• Late submission will result in ZERO mark.
• The work should be your own, copying from students or other resources will result in ZERO mark.
• Use Times New Roman font for all your answers.
Question One
Pg. 01
Learning
Outcome(s):
Explain the basic
principles of
programming,
concept of
language, and
universal
Question One
Write a java program that calculates the cost of individual items, including tax, and
prints the grocery bill. Your program must do the following:
1. Ask the user to enter his/her full name.
2. Print a welcome message using the user’s name.
3. Ask the user to enter the name of the item.
constructs of
4. Ask the user to enter the price and quantity of the item.
programming
5. Declare a constant variable that holds a tax rate equal to 15%.
languages.
3 Marks
6. Calculate the total price of the item, including the tax.
7. Print the grocery bill.
Note:
•
The class name of your Java program must be your first name.
•
Your answer should have the code as text as well as the screenshot of the
program output (using your own name) as a part of your answer. Otherwise,
zero marks will be awarded.
A typical run of the program
Question Two
Pg. 02
Learning
Outcome(s):
Question Two
3 Marks
Write a complete Java program that does the following:
Explain the basic
principles of
programming,
concept of
language, and
1. Ask the user to enter the last number and the second last number of his / her
student ID.
2. Stores the entered numbers in adequate variables.
3. Finds and prints the following using “printf”:
universal
–
The sum of the two numbers.
constructs of
–
The boolean value of comparing the equality of the two numbers using the
equality operator.
programming
–
languages.
The value of the first number is raised to the power of the second number
using a method from the class Math.
Note:
•
The class name of your Java program must be your first name.
•
Your answer should have the code as text as well as the screenshot of the
program output (using your own student ID) as a part of your answer.
Otherwise, zero marks will be awarded.
A typical run of the program
Question Three
Pg. 03
Learning
Outcome(s):
Question Three
2 Marks
Write a complete Java program that prints out the following information:
Explain the basic
principles of
programming,
concept of
language, and
1. Declare a String object and a variable to store your first name and ID.
2. Display your name and student ID in two separate lines using one println()
statement.
3. Replace your name with your father’s name using the assignment operator and
print the result.
universal
constructs of
4. Display the course name, course code, and your grade in a tabular format.
programming
(e.g.,
languages.
course name
course code
grade
computer programing
CS140
A
).
Note:
•
The class name of your Java program must be your first name.
•
Your answer should have the code as text as well as the screenshot of the
program output (using your own name and student ID) as a part of your
answer. Otherwise, zero marks will be awarded.
A typical run of the program