Skip to content
TORNLIFE More

Coding Problem

Started by Ass_Burgers [1045348] on in Technology.

5 replies · 79 views · thread synced · 5 days ago · View on torn.com
About this thread

Posts archived: 6 / 6 posts (100%) · the total is Torn's reply count + the opening post at the last fetch

Counted by TornLife from the archived posts.

Archived posts
6
Discussion span
→
People posting
4
Likes on archived posts
0
Authority score
6 / 100
Historical score
16 / 100
Story score
25 / 100
Engagement score
42 / 100
Ass_Burgers [1045348]

Hey, I just started programming about a month ago . I have an assignment and i dont know how to fix it this is what ive got so far . its a random number generator that says something if you hit the jackpot . i just need to get the main parts working then i will improve on it . this is what ive got so far

import java.util.*;
class Question1{
public static void main(String[] args){
int x = 777;
Scanner in = new Scanner(System.in);
System.out.print("Enter Number");
x = in.nextInt();

Random diceRoller = new Random();
for (int i = 0; i < 10; i++) {
int roll = diceRoller.nextInt(6) + 1;
System.out.println(roll);
}
if (x==777 ) {
System.out.println("Congradulations You Just Won 100 Tokens");
}



}
}
1875860 [1875860]

I hope this helps. I was too lazy to rename it, but it properly compares your input to the rolls now.

package javaapplication2;
import java.util.*;

public class JavaApplication2 {

public static void main(String[] args) {

int x;
Scanner in = new Scanner(System.in);
System.out.print("Enter Number");
x = in.nextInt();

Random diceRoller = new Random();
for (int i = 0; i < 10; i++) {
int roll = diceRoller.nextInt(6) + 1;
System.out.println("Roll: " + roll);

if (roll == x)
{
System.out.println("Congradulations You Just Won 100 Tokens");
}
}
}
}