Jump to content

zkeefe

New Members
  • Posts

    1
  • Joined

  • Last visited

Profile Information

  • Favorite Area of Science
    enigneering

zkeefe's Achievements

Lepton

Lepton (1/13)

0

Reputation

  1. Hello, I have been struggling with this program for a while and was wondering if anyone could help. I am trying to make a program where the user inputs an int 0-9 and then it will print out something like this: if user input=1 if user input = 3 I hope you guys get what im trying to say. so far i have: 1 **1 *21 321 import java.util.Scanner; public class Lab07 { public static void main(String[] args) { Scanner stdIn = new Scanner(System.in); int x; System.out.println("Enter a number 1-9: "); x = stdIn.nextInt(); while (x <=0 || x>=10) { System.out.println("Please enter a number 1-9: "); x = stdIn.nextInt(); } int i,j,k; for (i=1; i<= x;i++) { for (j=1;j<=x-i;j++) { System.out.print("*"); } for (k=x-i;k<=9;k++) { System.out.print(k); } System.out.println(); } stdIn.close(); } } THANKS!!!
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.