Question: Qu1) Write a Java program in a file called Three.java which uses a for loop to output the numbers from 1 to 10 (inclusive) followed
Qu1) Write a Java program in a file called Three.java which uses a for loop to output the numbers from 1 to 10 (inclusive) followed by their squares each on a new line. That is:
1 1
2 4
3 9
and so on.
Qu2) Write a Java program in a file called Four.java which prompts (asks) the user to input two words, on the same line (which must be read in using nextLine( ) ) and outputs to the screen the word that has the most number of characters. If both words have the same number of characters, the first word is output. You may assume that there is always one space between the words. For example: (user input is in bold)
Enter sentence >> zebra dragon
dragon
Qu3) Write a Java program in a file called Five.java that outputs a box of stars (*) on the screen. Prompt the user for how big (how many lines) the box should be. For example:
How many lines should the box be (enter an integer > 2): 4
****
****
****
****
Qu4) Write a Java program in a file called Six.java that prompts (asks) the user for a grade (text). If the grade entered by the user is: "high distinction" then the String "Very well done" is output to the screen "pass" then the String "well done" is output to the screen "not pass" then the String "need to work harder" is output to the screen
Note: grades are case insensitive. That means that PAss, pass and PaSs, for example, should produce the same result.
For any other grade the String "Questions are a good thing" is output to the screen.
Example:
java Six
Please enter a grade >> HiGH DistinCTION
Very well done
java Six
Please enter a grade >> Pass
well done
java Six
Please enter a grade >> grade, what grade?
Questions are a good thing
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
