Starting from:

$29.99

CSC1302 Lab 4- Loops and String Practice Solution


Purpose:
In this assignment, you will practice how to use while-loop and scanner class in Java. When defining your methods, you will use loops and operations on numbers/strings to complete some specific tasks.
Task1:
Write a java program called CountDigits that has two methods: main() and int countDigit(int n) . The main() ask user to input a number and call countDigit(int n) to print the number of digits in the inputted number.
Sample Expected Output of Task 1:

Task2: Write a java program to use scanner class to input your full name. If the input is a legit name that doesnot start with numbers (hint, using charAt and ASCII code), printout the length of the input name.
Sample Expected Output of Task 2:

Criteria:
1. Upload all of the .java and the .class files to the CSc1302 dropbox on http:// icollege.gsu.edu.
3. Please comment the important lines in the .java file as shown in the template. The important lines including but not limited to i) variables, ii) for-loop, iii) while-loop, iv) if-else statement, iv) methods. Please use your own words to describe what is your purpose to write this line. A .java file without comment will be graded under a 40% penalty.
4. Make sure that both the .java and .class files are named and uploaded to icollege correctly. If any special package is used in the program, be sure to upload the package too. Should you use any other subdirectory (whatsoever) your program would not be graded, and you will receive a 0 (zero).
5. No copying allowed. If it is found that students copy from each other, all of these programs will get 0.

More products