🔒 Closed Boolean help

Status
Not open for further replies.

Ez1o

Eternal Poster
Hello po, tanong ko lang if ano ang mali at kung ano dapat na gawin ko dito sa code ko.
IMG_20220210_204416.webp
Ang balak ko po kasi gumawa ng program na for loops.
Mag iinput ng name si user tapos mag iinput sya ng number kung ilang beses nya gusto iprint ang name nya.

E.g
Rius (name)
7 (times of repeat)


Then dapat naka list sya

E.g
1. Rius
2. Rius
3. Rius
4. Rius
5. Rius
6. Rius
7. Rius

//End


Sana po may makapansin


 
Very basic nian TS, eto code nian

Java:
    public static void main(String args[]) {
      System.out.println("name?");
      Scanner s = new Scanner(System.in);
      String nameToPrint = s.nextLine();
      System.out.println("how many times to print?");
      int timesToPrint = s.nextInt();
      for (int i = 0; i < timesToPrint; i++) {
          System.out.println((i + 1) + ". " + nameToPrint );
      }
    }

Bale ung input mo for times of repeat will be used dun sa for-loop
 
for loop , madali lng to .... okay namn yung sagot nung sa itaas.

yung sa code mo , I think wag mo na e repeat yung scanner = new scanner.
 
Very basic nian TS, eto code nian

Java:
    public static void main(String args[]) {
      System.out.println("name?");
      Scanner s = new Scanner(System.in);
      String nameToPrint = s.nextLine();
      System.out.println("how many times to print?");
      int timesToPrint = s.nextInt();
      for (int i = 0; i < timesToPrint; i++) {
          System.out.println((i + 1) + ". " + nameToPrint );
      }
    }

Bale ung input mo for times of repeat will be used dun sa for-loop
Salamat master hahahaha, laking tuwa ko eh. Bali aralin ko nalang kung paano nag work for me to learn na din. Maraming salamat ❤️
 
Status
Not open for further replies.

About this Thread

  • 4
    Replies
  • 410
    Views
  • 3
    Participants
Last reply from:
masterA2Z

Trending Topics

Online now

Members online
747
Guests online
3,999
Total visitors
4,746

Forum statistics

Threads
2,308,602
Posts
29,186,093
Members
1,192,089
Latest member
xincliere
Back
Top