CIS1068_Practice06_LoopsImplementation
Due date: In lab of Fri, Oct 14 Points: 100 points
Section:
Name:
• Attach both your NetBeans solution and outputs to this sheet.
• You need to match your outputs with the demos provided below.
• No hand-written submission.
• No emails submissions in any case.
• Comments in Java are beautiful, add them for more professional coding.
[Q1] Writing short Java programs
[1] Write a program that reads in an int from the keyboard, and stores the int in a variable x. Then write a loop that prints “Hello, world!” to the screen x times.
[2] Read a sentence from the keyboard, and count how many letter lowercase ’s’ or uppercase ‘S’ are in the sentence that the user enters.
[3] Read 3 Strings from the keyboard, and compute their total length.
Give me a number: 4 Hello, world! Hello, world! Hello, world! Hello, world!
Enter a sentence to count how many s or S are in there:
Sarah saw Susie standing somewhere swaying and singing some songs
11 s’s and S’s in your String
Enter 3 sentences and I will count their total length:
Enter Sentence #1:
Enter Sentence #2:
Enter Sentence #3:
Your sentences have total length of 80
Too much agreement kills a chat
Beauty is only skin-deep
Out of sight, out of mind
[4] Write a program that reads an int N from the keyboard, and prints out all of the squares between 1 and N2.
For instance, if the user enters 3 for N, the program should display this on the screen: 1*1=1
2*2=4
3*3=9
Enter a number: 3 1 *1 = 1
2 *2 = 4
3 *3 = 9