How to determine the amount of Bars from 2-10

So ive tried a few things with my code and cant seem to have it pick how many lines to output, (from 2-10). I was wondering if anyone would know a way to have this happen, to clarify, I want to have the amount of outputs (2-10) to output the number of times the lines will show, Sorry if this sounds confusing i dont know how else to explain it, heres the code, thanks!

import java.util.*;

public class AddNumbers3 //names the program
{
  public static void main(String[]args) //starts the main program
  {
    Scanner myInput = new Scanner(System.in);
   //input
   int n1, n2, n3, n4, n5, ;
   String a = "*";
   String b1 = 
   
   System.out.println("Tell me how many bars you would like from 2-20");
    b1 = myInput.nextInt(); 
   System.out.println("Tell me a number from 1-20");
    n1 = myInput.nextInt(); 
      System.out.println("Tell me a number from 1-20");
    n2 = myInput.nextInt(); 
      System.out.println("Tell me a number from 1-20");
    n3 = myInput.nextInt(); 
      System.out.println("Tell me a number from 1-20");
    n4 = myInput.nextInt(); 
      System.out.println("Tell me a number from 1-20");
    n5 = myInput.nextInt(); 
   
    //output
    for (String i=0; i<b1; i++) //number of bars
    {
      System.out.print("*" * n1);
    }
    for (int i=0; i<n1; i++) // paste a certain amount of times
    {
      System.out.print(a);
    }
    System.out.println();
    for (int i=0; i<n2; i++) // paste a certain amount of times
    {
      System.out.print(a);
    }
    System.out.println();
    for (int i=0; i<n3; i++) // paste a certain amount of times
    {
      System.out.print(a);
    }
    System.out.println();
    for (int i=0; i<n4; i++) // paste a certain amount of times
    {
      System.out.print(a);
    }
    System.out.println();
    for (int i=0; i<n5; i++) // paste a certain amount of times
    {
      System.out.print(a);
    }
    
    }//end main 
}//end class

Heres a bit of a newer version…


import java.util.*;

public class AddNumbers3 //names the program
{
  public static void main(String[]args) //starts the main program
  {
    Scanner myInput = new Scanner(System.in);
   //input
   int n1, n2, n3, n4, n5, n6, n7, n8, n9, n10, n11, n12, n13, n14, n15, n16, n17, n18, n19, n20, b;
   String a = "*";
   
   
   System.out.println("Tell me how many bars you would like from 2-20");
    b = myInput.nextInt(); 
    //bars
     for (int i=1; i<b; i++) //number of bars
     {
       
    //input from user
    System.out.println("Tell me a number from 1-20");
    n1 = myInput.nextInt(); 
    System.out.println("Tell me a number from 1-20");
    n2 = myInput.nextInt(); 
    System.out.println("Tell me a number from 1-20");
    n3 = myInput.nextInt(); 
    System.out.println("Tell me a number from 1-20");
    n4 = myInput.nextInt(); 
    System.out.println("Tell me a number from 1-20");
    n5 = myInput.nextInt(); 
    System.out.println("Tell me a number from 1-20");
    n6 = myInput.nextInt(); 
    System.out.println("Tell me a number from 1-20");
    n7 = myInput.nextInt(); 
    System.out.println("Tell me a number from 1-20");
    n8 = myInput.nextInt(); 
    System.out.println("Tell me a number from 1-20");
    n9 = myInput.nextInt(); 
    System.out.println("Tell me a number from 1-20");
    n10 = myInput.nextInt(); 
    System.out.println("Tell me a number from 1-20");
    n11 = myInput.nextInt(); 
    System.out.println("Tell me a number from 1-20");
    n12 = myInput.nextInt(); 
    System.out.println("Tell me a number from 1-20");
    n13 = myInput.nextInt(); 
    System.out.println("Tell me a number from 1-20");
    n14 = myInput.nextInt(); 
    System.out.println("Tell me a number from 1-20");
    n15 = myInput.nextInt(); 
    System.out.println("Tell me a number from 1-20");
    n16 = myInput.nextInt(); 
    System.out.println("Tell me a number from 1-20");
    n17 = myInput.nextInt(); 
    System.out.println("Tell me a number from 1-20");
    n18 = myInput.nextInt(); 
    System.out.println("Tell me a number from 1-20");
    n19 = myInput.nextInt(); 
    System.out.println("Tell me a number from 1-20");
    n20 = myInput.nextInt(); 
    
    //output
   
    for (int i=0; i<n1; i++) // paste a certain amount of times
    {
      System.out.print(a);
    }
    System.out.println();
    for (int i=0; i<n2; i++) // paste a certain amount of times
    {
      System.out.print(a);
    }
    System.out.println();
    for (int i=0; i<n3; i++) // paste a certain amount of times
    {
      System.out.print(a);
    }
    System.out.println();
    for (int i=0; i<n4; i++) // paste a certain amount of times
    {
      System.out.print(a);
    }
    System.out.println();
    for (int i=0; i<n5; i++) // paste a certain amount of times
    {
      System.out.print(a);
    }
       System.out.println();
    for (int i=0; i<n6; i++) // paste a certain amount of times
    {
      System.out.print(a);
    }
       System.out.println();
    for (int i=0; i<n7; i++) // paste a certain amount of times
    {
      System.out.print(a);
    }
       System.out.println();
    for (int i=0; i<n8; i++) // paste a certain amount of times
    {
      System.out.print(a);
    }
       System.out.println();
    for (int i=0; i<n9; i++) // paste a certain amount of times
    {
      System.out.print(a);
    }
       System.out.println();
    for (int i=0; i<n10; i++) // paste a certain amount of times
    {
      System.out.print(a);
    }
       System.out.println();
    for (int i=0; i<n11; i++) // paste a certain amount of times
    {
      System.out.print(a);
    }
       System.out.println();
    for (int i=0; i<n12; i++) // paste a certain amount of times
    {
      System.out.print(a);
    }
       System.out.println();
    for (int i=0; i<n13; i++) // paste a certain amount of times
    {
      System.out.print(a);
    }
       System.out.println();
    for (int i=0; i<n14; i++) // paste a certain amount of times
    {
      System.out.print(a);
    }
       System.out.println();
    for (int i=0; i<n15; i++) // paste a certain amount of times
    {
      System.out.print(a);
    }
       System.out.println();
    for (int i=0; i<n16; i++) // paste a certain amount of times
    {
      System.out.print(a);
    }
       System.out.println();
    for (int i=0; i<n17; i++) // paste a certain amount of times
    {
      System.out.print(a);
    }
       System.out.println();
    for (int i=0; i<n18; i++) // paste a certain amount of times
    {
      System.out.print(a);
    }
       System.out.println();
    for (int i=0; i<n19; i++) // paste a certain amount of times
    {
      System.out.print(a);
    }
       System.out.println();
    for (int i=0; i<n20; i++) // paste a certain amount of times
    {
      System.out.print(a);
    }
    
    }//end main 
}//end class

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.