🔒 Closed Guys pa help naman po dito badly needed lang.

Status
Not open for further replies.

BATANG Singkit 01

Forum Veteran
Guys pede makahingi ng codes dito, using inheritance need ko lang tlga nahihirapan na kasi ako jdoodle lang gamit ko. Salamat mga lods

image-bb7d0342-9807-4a5d-8148-8fe2251ae874.webp

Eto po yung code ko kaso di ko paalam paano gawin inheritance po ito jdoodle lang po kasi gamit ko.


import java.util.*;


class OutOfRangeException extends Exception{

public OutOfRangeException(){

super("Out of range\nGuess a number from 1 to 50!");

}

}

public class main1{


static void game(int guess, int target){}

public static void main(String args[]){

Scanner sc = new Scanner(System.in);

Random r = new Random();

int target = r.nextInt((50 - 1) + 1) + 1;

int guess = -1;

System.out.println("Guess a number from 1 to 50!");

int count=1;

do{

try{

guess = sc.nextInt();

if(guess<1 || guess>50)

throw new OutOfRangeException();

if(guess<target){

System.out.println("Too low. Try again.");

count+=1;

}

if(guess>target){

System.out.println("Too high. Try again.");

count+=1;

}

}

catch(OutOfRangeException e){

System.out.println(e.getMessage());

count+=1;

}

catch(InputMismatchException e){

System.out.println("Invalid Input\nGuess a number from 1 to 50!");

count+=1;

sc.nextLine();

}

}while(guess!=target);

}

}
 
Ito yt vid..
https://youtu♠be/zbVAU7lK25Q

Palitan mo ng dot yung ♠
Pwedi kang gumamit ng online compiler para dyan.. Search google..
 
Status
Not open for further replies.

About this Thread

  • 4
    Replies
  • 477
    Views
  • 3
    Participants
Last reply from:
vhin le

Trending Topics

Online now

Members online
945
Guests online
1,334
Total visitors
2,279

Forum statistics

Threads
2,272,141
Posts
28,940,467
Members
1,238,018
Latest member
Rjmnrs
Back
Top