Content text Assignment 02- Branching
LAB Tasks (No Need to Submit) 1. Write the Java code of a program to find the largest among three numbers entered by the user. Sample Input Output 100 23 -4 largest number: 100 5 17 -5 largest number: 17 2. Write a Java program that takes a student's numerical score as input as an integer and prints their corresponding letter grade according to the following grading system: Scores 90-100 85-89 70-84 57-69 50-56 <50 Grades A A- B C D F Sample Input Output 9 Your grade is F 82 Your grade is B
3. Write a Java code of a program that takes an integer number as user input and then determines if that number is divisible by both 5 and 7; otherwise display “No”. For example, numbers like 35, 70, 105, 140, 175, 210, 245, 280 etc. can be divisible by both 5 and 7. Sample Input Output 15 Invalid: Divisible by 5 Only 28 Invalid: Divisible by 7 Only 105 Divisible by Both 36 No 4. Write a Java program that will take a year as input and print whether that year is a leap year or not. ● A year may be a leap year if it is evenly divisible by 4. ● Years that are divisible by 100 (century years such as 1900 or 2100) cannot be leap years unless they are also divisible by 400. Sample Input Output 2020 2020 is a leap year 2001 2001 is not a leap year 1900 1900 is not a leap year 2000 2000 is a leap year 5. Let’s consider the following piecewise function: Design a Java code of a program that takes the value of x as user input and then displays the output based on the given piecewise function.