College of Computing and InformaticsBusiness Programming Languages
IT401
Assignment 1
Deadline: Day 9/4/2023 @ 23:59
Student Details:
Name: ###
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.
Learning
Outcome(s):
Explain the basic
principles of
programming,
concept of
language, and
universal
constructs of
Pg. 1
Question Four
Question One
2 Marks
The following Code should read the first and the second number of the student
ID then print the sum and divide it by zero if possible. However, there are three
errors in the code. Find each error and specify its type (syntax, runtime, or
logic) and correct them in the bellow table. Then, write the code after you
correct all errors and provide screenshot of the output.
Note:
1.The correct code should be tested using your first two numbers of your
student ID.
2. 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.
import java.util.Scanner;
public class Main {
public static void main(String[] Strings) {
Scanner input = new Scanner(System.in);
System.out.println(“Enter the first number of your student ID: “);
int number1 =input.nextInt();
Systm.out.println(“Enter the second number of your student ID: “);
int number2 =input.nextInt();
Pg. 2
Question Four
System.out.println(“The sum of two two numbers is ” + number1+number2);
System.out.println(“The sum devided by Zero is: ” + (number1+number2)/0);
}
}
Error
Type
Correction
Learning
Outcome(s):
Pg. 3
Recognize the
Question Four
concept of
Question Two
object-oriented
Write a complete Java program that does the following:
programming
1. Asks the user to enter his / her name, age, student ID, and GPA.
and creating
2. Stores the entered information in adequate variables.
classes.
3. Prints the student’s name, age, Student ID, and GPA using “printf” method.
All information should be printed in one line separated by tap space.
2 Marks
Note:
3.The class name of your Java program must be your first name followed by
(_) and your student ID.
4.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.
}
Learning
Outcome(s):
Pg. 4
Develop a
program based
on specification
using
programming
language
elements
including syntax,
Question Four
Question Three
2 Marks
Write a Java program that calculates and prints the area and volume of a
sphere. Your program should do the following:
•Ask the user to enter the radius of the sphere.
•Calculate the area of the sphere using the formula 4πr^2, where r is the radius,
and the value of π is approximately 3.14159.
•
Calculate the volume of the sphere using the formula (4/3)πr^3, where r is the
radius.
•
Print the calculated area and volume values to the console in a user-friendly
format using System.out.printf() method with proper formatting.
•
Your answer should have the code as text as well as the screenshot of the
program output
Output:
Learning
Outcome(s):
Instructors: State
the Learning
Outcome(s) that
match this
question
Pg. 5
Question Four
Question Four
2 Marks
Write a Java program that does the following:
•Print your full name.
•Ask the user to enter their gender As M or F
•If the gender is M, then print Male. Otherwise print Female.
•Your answer should have the code as text as well as the screenshot of the
program output.