Java Question

    April 21, 2024

Alfaisal University – College of Engineering Software Engineering Department Subject: SE 120 – Programming for Engineers Assignment 1 (Spring 2023-2024) Instructors Ms. Sarra Drine, Eng. Jomalyn Pancho, Eng. Muhammed Herwis Deadline Monday, 19-Feb-2024 @11:59PM Student Name: _____________________________________________________________ Student ID: _____________________________________________________________ Student Section: _____________________________________________________________ SE 120 – Assignment 1 – Spring 2023-2024 Question 1 – (Science: day of the week): Zeller’s congruence is an algorithm developed by Christian Zeller to calculate the day of the week. The formula is where: • • • • • h is the day of the week (0: Saturday, 1: Sunday, 2: Monday, 3: Tuesday, 4: Wednesday, 5: Thursday, and 6: Friday). q is the day of the month. m is the month (3: March, 4: April, . . ., 12: December). January and February are counted as months 13 and 14 of the previous year. 𝑦𝑒𝑎𝑟 j is 100 k is the year of the century (i.e., year % 100). Note all divisions in this exercise perform an integer division. Write a program that prompts the user to enter a year, month, and day of the month, and displays the name of the day of the week. Here are some sample runs: (Hint: January and February are counted as 13 and 14 in the formula, so you need to convert the user input 1 to 13 and 2 to 14 for the month and change the year to the previous year. For example, if the user enters 1 for m and 2015 for year, m will be 13 and year will be 2014 used in the formula.) Write the code here and attach screenshots of the output using some sample data as an example. Page 2 of 8 SE 120 – Assignment 1 – Spring 2023-2024 Question 2 – (Find the ASCII code of a character): Write a program that receives a character and displays its ASCII code (an integer between 0 and 127). Here is a sample run: Write the code here and attach screenshots of the output using some sample data as an example. Page 3 of 8 SE 120 – Assignment 1 – Spring 2023-2024 Question 3 – (Generate vehicle plate numbers): Assume that a vehicle plate number consists of three uppercase letters followed by four digits. Write a program to generate a plate number. Write the code here and attach screenshots of the output using some sample data as an example. Page 4 of 8 SE 120 – Assignment 1 – Spring 2023-2024 Question 4 – (Display numbers in a pyramid pattern): Write a nested for loop that prints the following output: Write the code here and attach a screenshot of the output. Page 5 of 8 SE 120 – Assignment 1 – Spring 2023-2024 Question 5 – (Count vowels and consonants): Assume that the letters A, E, I, O, and U are vowels. Write a program that prompts the user to enter a string, and displays the number of vowels and consonants in the string. Here is a sample run: Write the code here and attach screenshots of the output using some sample data as an example. Page 6 of 8 SE 120 – Assignment 1 – Spring 2023-2024 Question 6 – (Sum the digits in an integer): Write a method that computes the sum of the digits in an integer. Use the following method header: public static int sumDigits(long n) For example, sumDigits(234) returns 9 (= 2 3 4). (Hint: Use the % operator to extract digits and the / operator to remove the extracted digit. For instance, to extract 4 from 234, use 234 % 10 (= 4 ). To remove 4 from 234, use 234 / 10 (= 2 3 ). Use a loop to repeatedly extract and remove the digit until all the digits are extracted. Write a test program that prompts the user to enter an integer then displays the sum of all its digits. Write the code here and attach screenshots of the output using some sample data as an example. Page 7 of 8 SE 120 – Assignment 1 – Spring 2023-2024 Question 7 – (Sum series): Write a method to compute the following series: Write a test program that displays the following table: Write the code here and attach a screenshot of the output. Page 8 of 8

Trust your assignments to an essay writing service with the fastest delivery time and fully original content.

Verified