PRG 420 Week 3 Individual Assignment For While and Do While Loops

For this assignment, you will apply what you learned in analyzing for, while, and do-while loops by writing these statements yourself. The Java™ program you write should do the following:

  • Display a pyramid of asterisks onscreen (i.e., a nested for loop)
  • Display the integers 10 to 1 in decreasing order, one number per line (i.e., a while/do-whlie loop)
  • Add 7 until the sum becomes greater than 157, at which point the program should display both the sum and the number of 7s added

Complete this assignment by doing the following:

  1. Download and unzip the linked Week Three Coding Assigment Zip File.
  2. Add comments to the code by typing your name and the date in the multi-line comment header.
  3. Replace the following lines with Java™ code as directed in the file:
    • LINE 1
    • LINE 2
    • LINE 3
  4. Comment each line of code you add to explain what you intend the code to do and why you chose each type of loop.
  5. Test and modify your Java™ program until it runs without errors and produces the results as described above.

Note: Refer to this week’s analyzing code assignment if you need help.
Submit your Java source (.java) code file using the Assignment Files tab.


The solution consists of:

  • A Java program includes fully commented
  • A Netbeans project in case you want to run the project on your computer.
  • Screenshots while running program

  • Attachments [Move over files to preview content of those files]
    • PRG_420_Week_3.zip (81.35 KB)
      • Netbeans Project
        • PRG420Week3
          • pom.xml
          • src
          • target
            • classes
              • .netbeans_automatic_build
              • PRG420Week3.class
            • generated-sources
              • annotations
              • maven-status
                • maven-compiler-plugin
                  • compile
                    • default-compile
                      • createdFiles.lst
                      • inputFiles.lst
              • test-classes
                • .netbeans_automatic_build
        • PRG420-Week-3-Screenshot-1.png
        • PRG420-Week-3-Screenshot-2.png
        • Source Code
      Preview PRG420Week3.java
      xxxxxx xxxxx xxx420xxxx3 {
      xxxxxx xxxxxx xxxx xxxx(xxxxxx[] xxxx) {
      int linesOfAsterisks = 5; for (int i = 1; i <= linesOfAsterisks; i++) { // for each line... // LINE 1. ADD A NESTED FOR LOOP THAT DISPLAYS ONE ASTERISK ON LINE 1, TWO ASTERISKS ON LINE 2, 3 ASTERISKS ON LINE 3, ETC. for (int j=1; j <= i; j++) { // use for loop to print character * i times System.out.print('*'); }
      xxxxxx.xxx.xxxxxxx();
      }
      xxx xxx = 10;
      //xxxx 2. xxx x xxxx xxxx xxxxxxxx xxxxxxx 10 xx 1 xx xxxxxxxxxx xxxxx (xxxx: xxxxxxxxx xxxxxxxx)
      xxx (xxx x=xxx; x > 0; x--) { // xxx xxx xxxx xxxxxxxxx
      Preview PRG420Week3.java
      xxxxxx xxxxx xxx420xxxx3 {
      xxxxxx xxxxxx xxxx xxxx(xxxxxx[] xxxx) {
      int linesOfAsterisks = 5; for (int i = 1; i <= linesOfAsterisks; i++) { // for each line... // LINE 1. ADD A NESTED FOR LOOP THAT DISPLAYS ONE ASTERISK ON LINE 1, TWO ASTERISKS ON LINE 2, 3 ASTERISKS ON LINE 3, ETC. for (int j=1; j <= i; j++) { // use for loop to print character * i times System.out.print('*'); }
      xxxxxx.xxx.xxxxxxx();
      }
      xxx xxx = 10;
      //xxxx 2. xxx x xxxx xxxx xxxxxxxx xxxxxxx 10 xx 1 xx xxxxxxxxxx xxxxx (xxxx: xxxxxxxxx xxxxxxxx)
      xxx (xxx x=xxx; x > 0; x--) { // xxx xxx xxxx xxxxxxxxx



    Price: $19
    Buy Now

    Buy More Save More
    Buy at least TWO items & save up to 30% OFF your ENTIRE order!
    Rack up instant rebates in your shopping cart. Simply add items to your cart, and see the savings add up.
    Discounts will automatically be applied on eligible orders.

    Add to Cart