Skip to Content

Translate Page

Use of arrow keys when focused on the Google language option field will translate site content on the fly. Use your enter key to review all options and choose your selection before applying.
McFarland School District
McFarland High (9-12)
  • McFarland High (9-12)
    • McFarland High School
    • Academic & Career Planning (ACP)
    • Athletic & Activity Code of Conduct
    • Canvas Login
    • Clubs
    • Communications
    • Course Supply List
    • Daily Announcements
    • Daily Schedules
    • Family Handbook
    • Grading Handbook
    • Graduation Information
    • Library Media Services
    • Music
    • Office Staff
    • PBIS
    • Portfolio Resources
    • Progressive Behavior Response Plan
    • Report Suspicious Activity
    • Spartan Headquarters
    • Special Education
    • Sports
      • Boys Teams
        • Baseball
        • Basketball
        • Football
        • Golf
        • Hockey
        • Lacrosse
        • Soccer
        • Swimming
        • Tennis
      • Coed Teams
        • Cross Country
        • Track & Field
        • Wrestling
      • Girls Teams
        • Basketball
        • Dance
        • Golf
        • Hockey
        • Lacrosse
        • Soccer
        • Softball
        • Swimming
        • Tennis
        • Volleyball
      • 25-26 Sport Registration-Athletic Code Video
      • Athletic & Activity Code of Conduct
      • Concussion & Sudden Cardiac Arrest Info
      • Infinite Campus Sport Registration Info Sheet
      • Parent Resources
      • Parent Transportation Form
      • Physical Form
      • Spartan Sport Sponsors
      • Uniform Care Info
      • WIAA Medical Eligibility Form
    • Staff Directory
    • Student Services
      • Transcript Request (former students)
    • Youth Apprenticeship
    • Xello - Student
    • Web Design 1
      • Class Lessons
        • XHTML Tutorial
        • CSS Tutorial
        • Form Tutorial
        • Graphics
        • Dreamweaver
        • QuickMenu
        • Joomla!
      • Assignments
        • Site 1: Biography
        • Site 2: Fan Club
        • Site 3: Mixed Media
        • Site 4: Joomla!
      • Student Samples
        • Biography Sites
        • Fan Club Sites
        • Mixed Media Sites
        • Joomla! Sites
      • Helpful Sites
        • XHTML Help
        • CSS Help
        • Validation
        • QuickMenu
        • Joomla! Help
    • Web Design 2
      • Class Lessons
        • JavaScript Tutorial
        • PHP Tutorial
        • MySQL Tutorial
        • Admin - CMS
      • Assignments
        • Using JavaScript
        • For the Birds
      • Helpful Sites
        • JavaScript Tutorials
        • RegExp Help
        • Web Page Validation
    • Programming 1
      • Class Lessons
        • CLASS SET-UP
        • Logic Test
        • Class Preparation
        • Using BlueJ
        • --------------------
        • SET 1 LESSONS:
        • Printing
        • Variables
        • User Input
        • Random Number
        • Arithmetic
        • --------------------
        • SET 2 LESSONS:
        • If
        • Switch
        • --------------------
        • SET 3 LESSONS:
        • Looping
        • --------------------
        • SET 4-5 LESSONS:
        • Arrays
        • --------------------
        • SET 6 LESSONS:
        • String Manipulation
      • Problem Sets
        • Set 1: Basic Skills
        • Set 2: If & Switch
        • Set 3: Loops
        • Project: Craps
        • Set 4: Single Array
        • Set 5: Double Array
        • Set 6: Strings
      • Solution Sets
        • Problem Set 1
        • Problem Set 2
        • Problem Set 3
        • Problem Set 4
        • Problem Set 5
        • Problem Set 6
      • Helpful Sites
    • Programming 2
      • Class Lessons
        • Using BlueJ
        • What is an Object?
        • What is a Class?
        • GUI Programming
      • Problem Sets
        • Set 1 - Shapes
        • Set 2 - Exercises
        • Set 3 - Exercises
        • Set 4 - Exercises
        • Project - Adding
        • Set 5 - GUI by Hand
        • Project - NetBeans
        • Set 6 - NetBeans
        • Project - Life
        • Project - Slide Puzzle
        • Project - Matching
      • Solution Sets
        • Problem Set 1 (none)
        • Problem Set 2 (none)
        • Problem Set 3 (none)
        • Problem Set 4
  • Home
  • District
    • Referendum November 5, 2024
      • Impact Tax Calculator
    • Strategic Plan
    • School Board
      • Agendas, Minutes & Notices
      • Board Member Informational Brochure
      • District Policies
      • Meeting Calendar
      • Meeting Recordings
      • Members
      • Non-Discrimination Policy
      • Notice of Educational Options
      • Notices
      • Resolutions
    • Departments & Administration
      • District Administrator Message
        • Tarnutzer's Travels
      • Diversity, Equity, Inclusion & Belonging
      • Administrative Staff
      • Building & Grounds
        • Facility Use / Rental
      • Business Services
      • Finances
      • Health Services
      • McFarland Recreation Activities & Play (MRAP)
        • Current Events / News
        • Community Recreation Partners
      • Public Records Requests
      • School Nutrition
        • Lunch Menus
      • Special Education
        • What is Special Education?
        • Contact Information
        • Resources
      • Student Services
        • Community Resources
        • District Programs
        • Family Resources
        • Student Services Team Members
      • Summer School
      • Teaching & Learning
        • Assessments for Learning
        • Curriculum
        • Wisconsin Academic Standards
        • Early Literacy - Wisconsin Act 20
      • Transportation
        • Bus Safety Videos
        • StopFinder
    • Prospective Families & Staff
      • About McFarland
      • District Boundary Map
      • District Mission & Vision
      • Employment
      • Enrollment Process
        • Online Enrollment
      • Open Enrollment
      • Residency Questions
      • School and District Report Cards
    • Staff Resources
      • Assessment Calendar (District)
      • Assistive Technology
      • Bloodborne Pathogens Exposure Control Plan
      • Branding/Logos
      • Building & Grounds Info Sheet
      • Calendar Dates - Staff 25-26
      • Calendar Dates - Staff 26-27
      • Canvas Login
      • Educator Effectiveness
      • Employee Assistance Program
      • Employee Handbook
      • FAQ - Employee Services
      • Field Trip Requests
      • Finance Forms
      • FMLA
      • Fundraising
      • Hiring Procedure
      • HR and Business Services
      • HR HERMAN
      • Infinite Campus Staff Login
      • Insurance
      • Job Descriptions
      • Maintenance & Facilities Requests
      • Mentoring Resources
      • Payroll Forms
      • PD Points Tracker
      • SeeSaw Staff Login
      • Skyward
      • Student Teacher
      • Substitute Request
      • Technology (IT) Help Desk
      • Technology Department
      • Technology Orientation
      • Time-Off
      • TSG Info & Timelines
      • Web Site Admin
      • WECAN Links
      • Xello - Staff Login
  • Families
    • All
      • 2025-2026 School Hours
      • 2025-2026 Calendar Dates
      • 2026-2027 Calendar Dates
      • Calendar - All District
      • Canvas Login
      • Communications
      • Daily Schedules
      • Emergency Protocol
      • Handbooks
      • McFarland Mobile App
      • Online Registration
        • Registration Documents
        • Important Back To School Dates
      • Safety
      • Safety and Bullying Tip Line - SUSO
      • School and District Report Cards
      • Social Media
      • Spartan Headquarters
      • Supply Lists
    • Students
      • Canvas Student Login
      • Library Resources
    • Parents/Guardians
      • Absence Reporting
      • Advanced Learner (GT)
      • Canvas Parent Login
      • Drug & Alcohol Resources
      • Dyslexia Information Guide
      • English Learners (EL)
        • Eligibility
        • Philosophy
        • DPI Language Levels
        • Resources
      • Gun Safety Resources
      • Human Growth & Development Booklet
      • Joining Forces for Families
      • McFarland Music Boosters
      • School Nutrition
      • Special Education
      • Transportation
      • Volunteering
      • Volunteer Handbook
      • Weather Related Closures
    • Important Links
      • Drivers Ed
      • Google Apps
      • Infinite Campus
      • Lunch Menus
      • McFarland Public Library
      • Summer School
      • Work Permits
      • Xello - Student (w/Free ACT Method Test Prep
    • Other
      • McFarland Thistle
      • McFarland Youth Center
      • Outdoor Programs
        • Resources
      • McFarland School Forest
        • Bird Boxes
        • Bird Feeders
        • Bird Song Board
        • Fauna
        • Flora
        • Habitats
        • Silver Award
        • Our Supporters
    • Our District App
  • Community
    • Community Pool
    • Facilities Use / Rental
    • McFarland Education Foundation (MEF)
    • McFarland Performing Arts Center (PAC)
    • McFarland Public Library
    • McFarland Recreation, Activities & Play(MRAP)
    • School Visitors
    • Summer School
    • Village of McFarland
    • Volunteering
  • Contact Us
    • District Office
    • School Offices
    • Staff Directory
    • Web Site Feedback
    • Spartan Shout Outs
  • A-Z Links
  • Staff Resources
  • 2025-2026 Calendar Dates
  • See Something Say Something Reporting
  • Mobile App
  • 2026-2027 Calendar Dates

Schools

  • McFarland Primary School (4K-2)
  • Waubesa Intermediate (3-5)
  • Indian Mound Middle (6-8)
  • McFarland High (9-12)
  • Online Virtual Charter Schools
District Home

Important Links

  • Canvas Login
  • District Calendar
  • Lunch Menus
  • Infinite Campus - Student/Parent
  • Infinite Campus - Staff
  • Staff Directory

Set 3: Loops

McFarland High (9-12)

    • McFarland High School
    • Academic & Career Planning (ACP)
    • Athletic & Activity Code of Conduct
    • Canvas Login
    • Clubs
    • Communications
    • Course Supply List
    • Daily Announcements
    • Daily Schedules
    • Family Handbook
    • Grading Handbook
    • Graduation Information
    • Library Media Services
    • Music
    • Office Staff
    • PBIS
    • Portfolio Resources
    • Progressive Behavior Response Plan
    • Report Suspicious Activity
    • Spartan Headquarters
    • Special Education
    • Sports
      • Boys Teams
        • Baseball
        • Basketball
        • Football
        • Golf
        • Hockey
        • Lacrosse
        • Soccer
        • Swimming
        • Tennis
      • Coed Teams
        • Cross Country
        • Track & Field
        • Wrestling
      • Girls Teams
        • Basketball
        • Dance
        • Golf
        • Hockey
        • Lacrosse
        • Soccer
        • Softball
        • Swimming
        • Tennis
        • Volleyball
      • 25-26 Sport Registration-Athletic Code Video
      • Athletic & Activity Code of Conduct
      • Concussion & Sudden Cardiac Arrest Info
      • Infinite Campus Sport Registration Info Sheet
      • Parent Resources
      • Parent Transportation Form
      • Physical Form
      • Spartan Sport Sponsors
      • Uniform Care Info
      • WIAA Medical Eligibility Form
    • Staff Directory
    • Student Services
      • Transcript Request (former students)
    • Youth Apprenticeship
    • Xello - Student
    • Web Design 1
      • Class Lessons
        • XHTML Tutorial
        • CSS Tutorial
        • Form Tutorial
        • Graphics
        • Dreamweaver
        • QuickMenu
        • Joomla!
      • Assignments
        • Site 1: Biography
        • Site 2: Fan Club
        • Site 3: Mixed Media
        • Site 4: Joomla!
      • Student Samples
        • Biography Sites
        • Fan Club Sites
        • Mixed Media Sites
        • Joomla! Sites
      • Helpful Sites
        • XHTML Help
        • CSS Help
        • Validation
        • QuickMenu
        • Joomla! Help
    • Web Design 2
      • Class Lessons
        • JavaScript Tutorial
        • PHP Tutorial
        • MySQL Tutorial
        • Admin - CMS
      • Assignments
        • Using JavaScript
        • For the Birds
      • Helpful Sites
        • JavaScript Tutorials
        • RegExp Help
        • Web Page Validation
    • Programming 1
      • Class Lessons
        • CLASS SET-UP
        • Logic Test
        • Class Preparation
        • Using BlueJ
        • --------------------
        • SET 1 LESSONS:
        • Printing
        • Variables
        • User Input
        • Random Number
        • Arithmetic
        • --------------------
        • SET 2 LESSONS:
        • If
        • Switch
        • --------------------
        • SET 3 LESSONS:
        • Looping
        • --------------------
        • SET 4-5 LESSONS:
        • Arrays
        • --------------------
        • SET 6 LESSONS:
        • String Manipulation
      • Problem Sets
        • Set 1: Basic Skills
        • Set 2: If & Switch
        • Set 3: Loops
        • Project: Craps
        • Set 4: Single Array
        • Set 5: Double Array
        • Set 6: Strings
      • Solution Sets
        • Problem Set 1
        • Problem Set 2
        • Problem Set 3
        • Problem Set 4
        • Problem Set 5
        • Problem Set 6
      • Helpful Sites
    • Programming 2
      • Class Lessons
        • Using BlueJ
        • What is an Object?
        • What is a Class?
        • GUI Programming
      • Problem Sets
        • Set 1 - Shapes
        • Set 2 - Exercises
        • Set 3 - Exercises
        • Set 4 - Exercises
        • Project - Adding
        • Set 5 - GUI by Hand
        • Project - NetBeans
        • Set 6 - NetBeans
        • Project - Life
        • Project - Slide Puzzle
        • Project - Matching
      • Solution Sets
        • Problem Set 1 (none)
        • Problem Set 2 (none)
        • Problem Set 3 (none)
        • Problem Set 4
    • McFarland High School
    • Academic & Career Planning (ACP)
    • Athletic & Activity Code of Conduct
    • Canvas Login
    • Clubs
    • Communications
    • Course Supply List
    • Daily Announcements
    • Daily Schedules
    • Family Handbook
    • Grading Handbook
    • Graduation Information
    • Library Media Services
    • Music
    • Office Staff
    • PBIS
    • Portfolio Resources
    • Progressive Behavior Response Plan
    • Report Suspicious Activity
    • Spartan Headquarters
    • Special Education
    • Sports
      • Boys Teams
        • Baseball
        • Basketball
        • Football
        • Golf
        • Hockey
        • Lacrosse
        • Soccer
        • Swimming
        • Tennis
      • Coed Teams
        • Cross Country
        • Track & Field
        • Wrestling
      • Girls Teams
        • Basketball
        • Dance
        • Golf
        • Hockey
        • Lacrosse
        • Soccer
        • Softball
        • Swimming
        • Tennis
        • Volleyball
      • 25-26 Sport Registration-Athletic Code Video
      • Athletic & Activity Code of Conduct
      • Concussion & Sudden Cardiac Arrest Info
      • Infinite Campus Sport Registration Info Sheet
      • Parent Resources
      • Parent Transportation Form
      • Physical Form
      • Spartan Sport Sponsors
      • Uniform Care Info
      • WIAA Medical Eligibility Form
    • Staff Directory
    • Student Services
      • Transcript Request (former students)
    • Youth Apprenticeship
    • Xello - Student
    • Web Design 1
      • Class Lessons
        • XHTML Tutorial
        • CSS Tutorial
        • Form Tutorial
        • Graphics
        • Dreamweaver
        • QuickMenu
        • Joomla!
      • Assignments
        • Site 1: Biography
        • Site 2: Fan Club
        • Site 3: Mixed Media
        • Site 4: Joomla!
      • Student Samples
        • Biography Sites
        • Fan Club Sites
        • Mixed Media Sites
        • Joomla! Sites
      • Helpful Sites
        • XHTML Help
        • CSS Help
        • Validation
        • QuickMenu
        • Joomla! Help
    • Web Design 2
      • Class Lessons
        • JavaScript Tutorial
        • PHP Tutorial
        • MySQL Tutorial
        • Admin - CMS
      • Assignments
        • Using JavaScript
        • For the Birds
      • Helpful Sites
        • JavaScript Tutorials
        • RegExp Help
        • Web Page Validation
    • Programming 1
      • Class Lessons
        • CLASS SET-UP
        • Logic Test
        • Class Preparation
        • Using BlueJ
        • --------------------
        • SET 1 LESSONS:
        • Printing
        • Variables
        • User Input
        • Random Number
        • Arithmetic
        • --------------------
        • SET 2 LESSONS:
        • If
        • Switch
        • --------------------
        • SET 3 LESSONS:
        • Looping
        • --------------------
        • SET 4-5 LESSONS:
        • Arrays
        • --------------------
        • SET 6 LESSONS:
        • String Manipulation
      • Problem Sets
        • Set 1: Basic Skills
        • Set 2: If & Switch
        • Set 3: Loops
        • Project: Craps
        • Set 4: Single Array
        • Set 5: Double Array
        • Set 6: Strings
      • Solution Sets
        • Problem Set 1
        • Problem Set 2
        • Problem Set 3
        • Problem Set 4
        • Problem Set 5
        • Problem Set 6
      • Helpful Sites
    • Programming 2
      • Class Lessons
        • Using BlueJ
        • What is an Object?
        • What is a Class?
        • GUI Programming
      • Problem Sets
        • Set 1 - Shapes
        • Set 2 - Exercises
        • Set 3 - Exercises
        • Set 4 - Exercises
        • Project - Adding
        • Set 5 - GUI by Hand
        • Project - NetBeans
        • Set 6 - NetBeans
        • Project - Life
        • Project - Slide Puzzle
        • Project - Matching
      • Solution Sets
        • Problem Set 1 (none)
        • Problem Set 2 (none)
        • Problem Set 3 (none)
        • Problem Set 4

Problem Set 3: Loops

 

To complete this set of problems you must have gone through the following lessons:

 

  • All lessons for Problem Sets 1 & 2 
  • Loops

Section 1: FOR LOOPS


Problem 1
Use a for loop to produce the following output.
Output Example
**********
**********
**********

 

 

 

 

 

 

 


Problem 2
Using only 1 asterisk and a for loop, produce the following output.
Output Example
****************************************

 

 

 

 

 

 


Problem 3
Use a for loop to produce the following output.
Output Example
Number of times looped: 1
Number of times looped: 2
Number of times looped: 3
Number of times looped: 4
Number of times looped: 5
Number of times looped: 6
Number of times looped: 7
Number of times looped: 8
Number of times looped: 9
Number of times looped: 10

 

 

 

 

 

 

 

 

 

 

 

 


Problem 4
Use a for loop to print all of the integers that end in 4 from 4 to 84.
Output Example
4  14   24   34  44  54  64  74  84

 

 

 

 

 

 


Problem 5
Use a for loop to print all of the integers from 99 down to 11 where both numbers are the same. The output should be as shown below.
Output Example
99   88   77  66  55  44  33   22   11

Problem 6
Use a for loop to produce the following output.
Output Example
10...9...8...7...6...5...4...3...2...1...Blastoff!

 

 

 

 

 

 


Problem 7
Write a program that will allow a number to be entered. Use the number as a step value, print the resulting numbers from 8 and 20.
Output Example
Enter the step value: 4
8 12 16 20

Problem 8
Use a for loop to produce the table portion (the bold selection) of the following output. (Hint: the value of x should start at 4 and end at 10)
Output Example
X     X^2     X^3
--------------------
4     16       64
6     36       216
8     64       512
10   100     1000

Problem 9
Using a for loop write a program that allows the ages of 3 persons to be entered, one at a time. The computer will then let them know if they are old enough to drive. Include the blank lines.
Output Example
Enter the age of person number 1: 12
You must wait 4 years to drive.

Enter the age of person number 2: 18
You can drive.

Enter the age of person number 3: 4
You must wait 12 years to drive.

Goodbye.

Problem 10
The Cheap Stay Motel has 25 rooms. Using a for loop have the computer print a label for each room's door indicating the room number.
Output Example
--------------------------
Cheap Stay Motel
       Room 1
--------------------------

--------------------------
Cheap Stay Motel
       Room 2
--------------------------

etc.... up to room...

--------------------------
Cheap Stay Motel
       Room 25
--------------------------

 

Problem 11
In a for loop have the computer generate 10 random numbers ranging from 1 to 10. The computer should print whether the numbers are less than 5, greater than 5 or equal to 5.
Output Example
On turn 1 the number 6 was chosen and found to be greater than 5.
On turn 2 the number 5 was chosen and found to be equal to 5.
...
On turn 10 the number 2 was chosen and found to be less than 5.

Problem 12
In a for loop have the computer randomly generate three numbers from 5 to 15. The output should be as shown below. Use a counter in the loop to calculate the total.
Output Example
The numbers chosen are: 7 12 6
The sum is 25.

Problem 13
Using a for loop write a program that finds the sum of the odd integers from 1 to 15. The output should be as shown below.
Output Example
The sum of 1+3+5+7+9+11+13+15 is 64

Problem 14
In a for loop have the computer randomly generate 1000 numbers from 0 to 9. The computer should print the total of numbers that were odd and the total that were even.
Output Example
There were 535 even numbers randomly chosen.
There were 465 odd numbers randomly selected.

Problem 15
Write a program that allows the user to enter a number. Have the computer calculate and print all the numbers that are factors of the number entered.
Output Example
Enter a positive whole number please: 12
The factors of 12 are 1 2 3 4 6 12

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Section 2: WHILE LOOPS

 

 


Problem 16
Write a program that simulates the rolling of a pair of dice. The computer should keep on rolling until a 12 is rolled.
Output Example
Roll 1 = 5
Roll 2 = 7
Roll 3 = 12
A 12 was rolled, program terminated.

Problem 17
Write a program that asks for a name and a password and will not continue until the correct name and password are entered.
Output Example
Enter user name: Jim
Enter a password: dude
Either the user or password are incorrect, please try again.
Enter user name: Bob
Enter a password: tomato
Welcome Bob, you now have access to the file server.

Problem 18
Write a program that allows the computer to randomly select a number from 1 to 100. Have the user guess the number selected by the computer. The user should keep on guessing until the correct number is chosen. The output should be as shown below.
Output Example
Guess my number: 50
Too high.

Guess my number: 25
Too low.

Guess my number: 35
Too high.

Guess my number: 32
Correct!!

Problem 19
Modify the previous program so that the user is allowed only 6 guesses. The output should be as shown below.
Output Example
Guess my number, you have 6 guesses left: 75
Too low.
Guess my number, you have 5 guesses left: 90
Too high.
Guess my number, you have 4 guesses left: 85
Too low.
Guess my number, you have 3 guesses left: 86
Too low.
Guess my number, you have 2 guesses left: 89
Too high.
Guess my number, you have 1 guess left: 88
Too high.
Sorry, you lose. The number was 87.

 

 

 


Problem 20
Write a program that allows the user to input the numbers of times the computer should choose a random number ranging from 1 to 20. Restrict the entry from 3 to 8. The computer should print the numbers selected and a total as shown below.
Output Example
Enter a number from 3 to 8: 10
Invalid entry.
Enter a number from 3 to 8: 0
Invalid entry.
Enter a number from 3 to 8: 4

The numbers chosen are: 12 10 18 15
The total is 55.

Problem 21

Write a program that allows the user and computer to alternately select numbers from 3 to 12. The numbers are totaled after each entry. A winner is declared when the total is greater than 100. The last one to enter a number is the winner. Have the computer ask whether the user wishes to go first or second. The computer should disallow cheating.

 

Special Instructions: When solving a more complex problem such as this one it is a good idea to have a plan of attack. You must first break the large problem down into smaller parts. Begin the coding by working on each small part until it works correctly. Add more parts until the complete problem is solved.

This problem should be broken down into these parts:

  1. Code for a simplified version of the game.
    • Write the game code for a basic version of the game that does not include taking turns or playing again. Have the player enter a value and then have the computer take a turn. Use a while loop so the game continues until the total value exceeds 100.
  2. Code to prevent cheating.
    • Add a while loop around the code that allows the player to enter a value. The loop should be written so that the game only accepts values from 3 to 12 too be used.
  3. Code for starting first or second.
    • Before the code of the game write code that asks the user whether he/she would like to go first or second. Place a while loop around the code so that only the values 1 or 2 are accepted as valid entries.
    • Change the code of the game so that it can alternate turns. You will need to use If to separate the user's turn from the computer's.

 

Output Example
Would you like to go first or second? (Enter 1 or 2): 1
Enter your choice (3-12): 10
The total is now 10
I choose 3
The total is now 13
Enter your choice (3-12): 10
The total is now 23
I choose 8
The total is now 31
...
The total is now 92.
Enter your choice (3-12): 10
The total is now 102
You have won!!!
Would you like to play another round? (Y/N): N
Goodbye.

 

 

 

 

 

Section 3: NESTED LOOPS

 

 


Problem 22
Using only 1 question mark and a nested for loop have the computer print a rectangle consisting of five lines of twenty question marks each.
Output Example
????????????????????
????????????????????
????????????????????
????????????????????
????????????????????

Problem 23
Modify the previous program so that the user can enter the number of rows, the number in each row and the letter to use.
Output Example
Enter the number of rows: 2
Enter the width of the row: 5
Enter the letter to use: H

HHHHH
HHHHH

Problem 24
Write a program that uses nested for loops to produce the following output.
Output Example
&
&&
&&&
&&&&
&&&&&

 

 

 

 

 

 

 

 


Problem 25
Modify the previous program to produce the following output.
Output Example
&&&&&
&&&&
&&&
&&
&

 

 

 

 

 

 

 

 

 


Problem 26
Use nested loops to produce the following output.
Output Example
The value of the outside loop is 1
    The value of the inside loop is 1
    The value of the inside loop is 2
    The value of the inside loop is 3
The value of the outside loop is 2
    The value of the inside loop is 1
    The value of the inside loop is 2
    The value of the inside loop is 3
The value of the outside loop is 3
    The value of the inside loop is 1
    The value of the inside loop is 2
    The value of the inside loop is 3

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 


Problem 27
Write a program that uses nested for loops to produce the following output.
Output Example
X=20
Y=1 Y=2 Y=3
X=21
Y=1 Y=2 Y=3
X=22
Y=1 Y=2 Y=3
X=23
Y=1 Y=2 Y=3
X=24
Y=1 Y=2 Y=3

 

 

 

 

 

 

 

 

 

 

 

 

 


Problem 28
Write a program that calculates and prints all of the possible combinations of coins that add up to 50 cents using quarters, dimes and nickels.
Output Example
QuartersDimesNickels
0010
018
... some results omitted to save space ...
200

Problem 29

Modify the previous program so that it includes 50 cent pieces and the coins must total one dollar.

Output Example
Half DollarsQuartersDimesNickels
00020
00118
... some results omitted to save space ...
2000

 

 

 

 

 

 

 

 

 

 

 


Problem 30
Write a program that uses nested for loops to calculate the factorials of the numbers 1 through 10. (Hint: the factorial of 5, shown as 5!, is 1*2*3*4*5)
Output Example
1! Is 1
2! Is 2
3! Is 6
4! Is 24
5! Is 120
6! Is 720
7! Is 5040
8! Is 40320
9! Is 362880
10! Is 3628800

Problem 31
Using nested for loops write a program that finds all of the prime numbers from 1 to 50.
Output Example
The prime numbers are: 2 3 5 7 11 13 17 19 23 29 31 37 41 43 47

 

 

McFarland School District Home

McFarland School District

Grades: 9 - 12

Contact Information

  • McFarland High School (9-12)

    5103 Farwell Street
    McFarland, WI 53558
  • Phone

    608 838-3166
  • Fax

    608 838-4562

Social Media

  • McFarland School District Social Facebook
  • McFarland School District Social Instagram
McFarland School District Mark

© 2025 McFarland School District

  • Non-Discrimination Statement
CMS4Schools