Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

PLEASE DO NOT COPY PASTE FROM GOOGLE AND CHEGG. Question # 1 Write a Code (in C#) and provide snapshots of your given input and

image text in transcribed

PLEASE DO NOT COPY PASTE FROM GOOGLE AND CHEGG.

Question # 1 Write a Code (in C#) and provide snapshots of your given input and obtained output. a (a): You need to create an integer array of size 4 to store marks of 4 students. The total marks is 10, that means that the given marks must not be greater than 0. Take user input to enter the elements in an array. The loop for entering elements should run from 1 to 6. . .. You should receive an index out of bound exception. Also, you may receive NumberFormatException when user tries to input String in the Integer array. Also throw an IllegalArgumentException if the input number is greater than 10. (b):- Correct the following code and add appropriate exception handling. To handle exception in an elegant manner, asks user to re-enter data until he enters data in correct format. Also, add a finally block that shows message as follow: o. If try completes successfully, Finally prints The program has been completed successfully o. Finally runs after catch block, prints Finally printsRepeating input from start again? public class NewClass { public static void main(String[] args) { Scanner scan =new Scanner(System.in); int month = Integer.parseInt(JOptionPane.showInputDialog("Enter month as integer")); int day = Integer.parseInt(JOptionPane.showInput Dialog("Enter day as integer")); int year =Integer.parseInt(JOptionPane.showInput Dialog("Enter year as integer")); SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy"); Date aDate = new Date(dDay+"/"+dMonth+"/"+dYear); System.out.println(dateFormat.format(aDate)); } }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions