Need Computer Science Mod 5 Loops Assignment /Computer Science

 

Need Computer Science Mod 5 Loops Assignment /Computer Science

Design and implement a Java program (name it PasswordTest) that accepts a string from the user and evaluates it as a password, giving it a valid or invalid verdict. The program must use a loop to parse the password string. A good password will have at least 8 characters and includes at least one lower-case letter, at least one upper-case letter, at least one digit, and at least one character that is neither a letter nor a digit. Your program will need to check each character in the string in order to render a verdict (in other words, do not use the String class instance method matches(), the Pattern class static method matches(), or any other method which parses the entire password string). For example, CS1301/18 is invalid password. The program should display the entered password and the program’s judgment as to its validity. For example,

Entered Password: CS1301/18 
Verdict:          Invalid

Document your code, and organize and space out your outputs as shown. Design your program such that it allows the user to re-run the program with a different inputs in the same run.

(you can select program 2 or 3 to complete.  You can submit three (3) programs for Mod_5 programs) 

Program_2:

Write a Java program (called LoopTriangel) that uses nested loops to print out the following shape. See chapter 5 slides for related example.

(NOTE: The approach implemented for this exercise must add one asterisk to the shape each iteration of the inner loop.)

**********

*********

********

*******

******

*****

****

***

**

*

Program_3:

Design and implement a Java program for programming exercise 5.18, page 194, from the textbook (name it Patterns). Document your code, and organize and space the outputs. Divide your code into 4 sections, one for each pattern. Notice that your program will print the patterns one after the other, not next to each other as shown in the textbook. Use escape characters and formatting objects when applicable.

Program_4:

Write a program for Programming exercise 5.29, page 196 that promote the user to enter the year and first day of the year and displays the calendar table for the year. For example, if the user entered the year 2013, and 2 for Tuesday, January 1, 2013, your program should display the calendar for each month in the year, as follows:

Submission:

· Save all programs.

· Please submit /attach all your programs collectively as a .Compressed zip file via http://d2l.kenensaw.edu each Module Assignment/Dropbox on or before Due date (Refer to Due date on each Module/Assignment on D2L)

Mod_5 – Ch5 Assignments – Loops/Mod_5 – Ch5 Sample Programs – Loops.docx

CS 1301 Programming Principles I

Sample Programs

Mod_5 -Chapter 5 – Loops

Use JGrasp to complete the following programs and understand what they do.

Save all programs for future reference as they illustrate essential programming features and syntax that you may use in other labs and Assignments.

Excercies_1:

/* * Course: CS 1301 * Section: XX * Professor: XXXX * Name: XXXX * Assignment #: XXXx */ //***************************************************************** // Average.java Author: Lewis/Loftus // Demonstrates the use of a while loop with a sentinel value. //***************************************************************** import java.text.DecimalFormat; import java.util.Scanner; public class Average { //—————————————————————– // Computes the average of a set of values entered by the user. // The running sum is printed as the numbers are entered. //—————————————————————– public static void main (String[] args) { int sum = 0, value, count = 0; double average; Scanner scan = new Scanner (System.in); System.out.print (“Enter an integer (0 to quit): “); value = scan.nextInt(); while (value != 0) // enter sentinel value of 0 to terminate loop { count = count + 1; sum = sum + value; System.out.println (“The sum so far is ” + sum); System.out.print (“Enter an integer (0 to quit): “); value = scan.nextInt(); } System.out.println (); if (count == 0) System.out.println (“No values were entered.”); else { average = (double)sum / count; DecimalFormat fmt = new DecimalFormat (“0.###”); System.out.println (“The average is ” + fmt.format(average)); } } }

***********************************************************************************************************************************

Excercies_2:

/* * Course: CS 1301 * Section: XX * Professor: XXXX * Name: XXXX * Assignment #: XXXx */ //******************************************************************** // WinPercentage.java Author: Lewis/Loftus // Demonstrates the use of a while loop for input validation. //******************************************************************** import java.text.NumberFormat; import java.util.Scanner; public class WinPercentage { //—————————————————————– // Computes the percentage of games won by a team. //—————————————————————– public static void main (String[] args) { final int NUM_GAMES = 12; int won; double ratio; Scanner scan = new Scanner (System.in); System.out.print (“Enter the number of games won (0 to ” + NUM_GAMES + “): “); won = scan.nextInt(); while (won < 0 || won > NUM_GAMES) { System.out.print (“Invalid input. Please reenter: “); won = scan.nextInt(); } ratio = (double)won / NUM_GAMES; NumberFormat fmt = NumberFormat.getPercentInstance(); System.out.println (); System.out.println (“Winning percentage: ” + fmt.format(ratio)); } }

Excercies_3:

/* * Course: CS 1301 * Section: XX * Professor: XXXX * Name: XXXX * Assignment #: XXXx */ //******************************************************************** // ReverseNumber.java Author: Lewis/Loftus // Demonstrates the use of a do loop. //******************************************************************** import java.util.Scanner; public class ReverseNumber { //—————————————————————– // Reverses the digits of an integer mathematically. //—————————————————————– public static void main (String[] args) { int number, lastDigit, reverse = 0; Scanner scan = new Scanner (System.in); System.out.print (“Enter a positive integer: “); number = scan.nextInt(); do { lastDigit = number % 10; reverse = (reverse * 10) + lastDigit; number = number / 10; } while (number > 0); System.out.println (“That number reversed is ” + reverse); } }

Excercies_4:

/* * Course: CS 1301 * Section: XX * Professor: XXXX * Name: XXXX * Assignment #: XXXx */ //******************************************************************** // Multiples.java Author: Lewis/Loftus // Demonstrates the use of a for loop. //******************************************************************** import java.util.Scanner; public class Multiples { //—————————————————————– // Prints multiples of a user-specified number up to a user- // specified limit. //—————————————————————– public static void main (String[] args) { final int PER_LINE = 5; int value, limit, mult, count = 0; Scanner scan = new Scanner (System.in); System.out.print (“Enter a positive value: “); value = scan.nextInt(); System.out.print (“Enter an upper limit: “); limit = scan.nextInt(); System.out.println (); System.out.println (“The multiples of ” + value + ” between ” + value + ” and ” + limit + ” (inclusive) are:”); for (mult = value; mult <= limit; mult = mult + value) { System.out.print (mult + “\t”); // Print a specific number of values per line of output count = count +1; if (count % PER_LINE == 0) System.out.println(); } } }

Now, use the above programs for guidance to complete the

Programming Assignments

NO points for this Sample Programs

Submission:

· Save all programs.

· Please submit via http://d2l.kenensaw.edu

· Attached on each Module, Labs Assignments

Note: Please submit (upload) the Lab assignments collectively on each Module as a Zip File.

(Include comments)

Order from us and get better grades. We are the service you have been looking for.