[SOLVED] SOLVED: Assignment3

25.00 $

Programming resource
Digital learning resource
Category:
Practical programming resource
Suitable for guided study and reference
Tutor guidance available when needed

Description

5/5 - (3 votes)

1. Rewrite the following set of if statements using a nested if-else structure. if (score = 90) grade = ‘A’; if (score = 80 && score < 90) grade = ‘B’; if (score = 70 && score < 80) grade = ‘C’; if (score = 60 && score < 70) grade = ‘D’; if (score < 60) grade = ‘F’; 2. Rewrite the following nested if-else statement as an equivalent switch statement. if (letter == ‘A’ | | letter == ‘a’) System.out.println(“Excellent”); else if (letter == ‘B’ | | letter == ‘b’) System.out.println(“You can do better”); else if (letter == ‘C’ | | letter == ‘c’) System.out.println(“Try harder”); else if (letter == ‘D’ | | letter == ‘d’) System.out.println(“Try much harder”); else System.out.println(“Try another major! “); Write a program called Assignment3 (saved in a file Assignment3 .java) that asks a user to enter two strings. First, the program prompts: Please enter a string. The program should read in the string, and prompts: Please enter another string. The program reads in the string and performs the following:  checks if each string’s length is odd or even.  checks if two strings are same or different.  checks which string is lexically larger, or they are same.  prints out the first character (index 0) of each string  prints out a new string consisting of the first string concatenated (appended) with the second string.  prints out two strings using upper case letters. Here is the output your program should produce when the user enters the string shown in bold:

Resource details

Understand the Task Before You Use the Resource

Review the requirements, identify the programming concepts involved, study the implementation and test your understanding with your own examples and modifications.