Lab week2 DPIT111 Assignment 3 Week 6-7 Objectives • Get familiar with relational and logical operators • Get familiar with switch-case statement • Get familiar with while loop and for loop Assignment...

1 answer below »
All information in pdf file .


Lab week2 DPIT111 Assignment 3 Week 6-7 Objectives • Get familiar with relational and logical operators • Get familiar with switch-case statement • Get familiar with while loop and for loop Assignment 3 (12%) is marked on a scale from 0-12 marks. Important notices: This assignment is scheduled to be done in Week 6-7 (Monday 3 August - Saturday 15 August 19:00). Comments for your work can be checked on Moodle site. You may be asked questions about your code. Your marks will be deducted if you could not answer the questions presented by the assessor. 1. Students must submit all assessment tasks by the due date or penalties will be applied. No. of calendar days late Penalty 1 10% of the original mark. 2 20% of the original mark. 3 30% of the original mark. More than 3 A mark of zero will be awarded for the assessment. 2. Make sure that you include following personal information in every file, otherwise it will result in 0 points. /*------------------------------------------------------ My name: My subject code: My student number: My email address: Assignment number: -------------------------------------------------------*/ 3. Ensure each file in your submission is runnable, compiling error in your file will result in 0 points for the current question. If it is runnable, though it fails to realize all functionalities, you can get partial points for what you have done. Question 1 (2 mark) : Write a program called PrintNumberInWord which prints "ONE", "TWO",... , "NINE", "OTHER" if the input integer is 1, 2,... , 9, or other, respectively using switch-case statements. REQUIREMENTS • Your code must use switch-case statement. • The user input is always correct (input verification is not required). • Your code must work exactly like the following example (the text in bold indicates the user input). Example of the program output: Example 1: Please enter an integer: 1 ONE Example 2: Please enter an integer: 12 OTHER Question 2 (4 mark) : Assume there is an enum type variable declared as follows: enum Day {SUNDAY, MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY} Write a program to ask the user to input an integer, decide and generate the output according to the user input and the enum variable, and finally display as the example. REQUIREMENTS • Your code must use switch-case statement. • The user input is always correct (input verification is not required). • Your code must work exactly like the following example (the text in bold indicates the user input). Example of the program output: Example 1: Enter an integer in [1, 7]: 1 You have lecture on MONDAY Example 2: Enter an integer in [1, 7]: 2 It is time to review lecture notes and lab exercises Example 3: Enter an integer in [1, 7]: 3 You have lab on WEDNESDAY or FRIDAY Example 4: Enter an integer in [1, 7]: 4 It is time to review lecture notes and lab exercises Example 5: Enter an integer in [1, 7]: 5 You have lab on WEDNESDAY or FRIDAY Example 6: Enter an integer in [1, 7]: 6 It is time to review lecture notes and lab exercises. Example 7: Enter an integer in [1, 7]: 7 It is time to review lecture notes and lab exercises. Example 8: Enter an integer in [1, 7]: 9 Please enter a number in [1, 7] Example 9: Enter an integer in [1, 7]: -1 Please enter a number in [1, 7] Question 3 (4 mark) : Write a program to produce the sum and the average of 1, 2, 3, ..., to N, where N is a positive integer number entered by the user. The program should use while-loop. REQUIREMENTS • Your code must use while-loop statement. • The user input is always correct (input verification is not required). • Your code must work exactly like the following example (the text in bold indicates the user input). Example of the program output (the text in bold indicates the user input): Example 1: Please input a positive integer number N: 8 The sum from 1 to 8 is: 36 The average is: 4.5 Example 2: Please input a positive integer number N: 100 The sum from 1 to 100 is: 5050 The average is: 50.5 Question 4 (2 mark) : Write a program that displays the following pattern using two nested for- loops. REQUIREMENTS • Your code must use nested for-loops. • Your program should use only the following 3 output statements, one of EACH of the followings: System.out.print("#"); // print # System.out.print("-"); // print - System.out.println(); // print a newline • The user input is always correct (input verification is not required). • Your code must work exactly like the following example (the text in bold indicates the user input). Example of the program output: Example 1: Enter the number of rows: 6 The pattern is as follows: ###### ----- #### --- ## - Example 2: Enter the number: 5 The pattern is as follows: ##### ---- ### -- # Submission requirements: 1. Put the solution to Question 1 in a text file (.txt) and upload this file to Part 1 of the submission link; put the solution to Question 2 in a text file (.txt) and upload this file to Part 2 of the submission link; put solutions to Question 3 in a text file (.txt) and upload this file to Part 3 of the submission link; put the solution to Question 4 in a text file (.txt) and upload this file to Part 4. The submission link is called Assignment 3 Submission under Week 6 Section on the subject Moodle site. 2. Submission via email is not acceptable without permission. 3. Enquiries about the marks can only be made within a maximum of 1 week after the assignment results are published. After 1 week the marks cannot be changed. Mark deductions: late submission, compilation errors, incorrect result, program is not up to spec, poor comments, poor indentation, meaningless identifiers, required numeric constants are not defined, the program uses approaches which has not been covered in the lectures. The deductions here are merely a guide. Marks may also be deducted for other mistakes and poor practices. END OF THE ASSIGNMENT  Get familiar with relational and logical operators
Answered Same DayAug 14, 2021

Answer To: Lab week2 DPIT111 Assignment 3 Week 6-7 Objectives • Get familiar with relational and logical...

Aditya answered on Aug 14 2021
130 Votes
/*------------------------------------------------------
My name:
My subject code:
My student num
ber:
My email address:
Assignment number:
-------------------------------------------------------*/
import java.util.Scanner;
public class PrintNumberInWord
{
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
System.out.print("Please enter an integer: ");
int number = sc.nextInt();
switch(number)
{
case...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here