Write an assignment statement that computes the square root


Part 1: Written Exercises

Note: The answers to the following questions should be typed in the block of comments in the Assignemnt3.java file. Please make sure they're commented out. Type them neatly and make them easy to read for the graders.

Exercise1: What output is produced by the following code fragment?

String m1, m2, m3;

m1 = "Java Programming";

m2 = m1.toLowerCase( );

m3 = m1 + " " + m2;

System.out.println(m3.replace('a','o'));

Exercise2: Write an assignment statement that computes the square root of the sum of num1 and num2 and assigns the result to num3.

Exercise3: What output is produced by the following code fragment?

int num = 57, max = 35;

if (num >= max*2)

System.out.println("orange");

System.out.println("lemon");

System.out.println("apple");

Part 2: Programming

Write a complete Java program in a source file to be named Assignment3.java.

The program should ask a user to enter two strings.
First, the program prompts:

Please enter a string.

The program should read in the string a user enters, 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:

Sample Output: (the user enters the string shown in bold)

Please enter a string.

Apple

Please enter another string.

Orange

The first string's length is odd.

The second string's length is even.

The two strings are different.

The second string is lexically larger.

The first character of the first string is A

The first character of the second string is O

The concatenation of two strings is "AppleOrange"

The first string using upper case letters: APPLE

The second string using upper case letters: ORANGE

Request for Solution File

Ask an Expert for Answer!!
C/C++ Programming: Write an assignment statement that computes the square root
Reference No:- TGS02882086

Expected delivery within 24 Hours