Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
Buy OSRS Gold

Sell OSRS Gold

mattl103

Registered
  • Content Count

    6
  • Joined

  • Last visited

  • Feedback

    0%

Community Reputation

0 Neutral

About mattl103

  • Rank
    New Botter

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. Hello i'm a new Java coder and im starting to make one of my firsts "cool" Java projects. It's a flower game program. It works as follows: •You first choose one number which would equal a flower colour, for example number 1 would equal red. •You then choose an ammount to bet. •A random color pops on the console. If you guessed it then your bet multiplies by 2. Else, you loose. I would really appriciate if some one would help me create a "Wallet System". You would basically start with a default wallet. If you win, your bet multiplies by 2 as the program already does, but your wallet is now higher, and you can eventually bet more. If you loose, your wallet's balance would go down and you will now have to bet lower.. I would like to do it so that every time you run the program, your wallet does not reset. I would like to know how can i instead of typing a number to select my flower colour, i could just type in the flower's name. Like red, or yellow. I'l leave you my game's code down here: import java.util.Random; //Imports import java.util.Scanner; public class main { public static String[] flowerGame = {"Red" , "Purple", "pastel", "yellow", "orange", "rainbow"}; //Array. public static Random rand = new Random(); //Makes new Random number Gen. public static Scanner scan = new Scanner(System.in); //Makes new Scanner. public static int random; public static int number; public static int bet; public static int doublebet; public static void main(String[] args) { System.out.println("Please enter a number 0 to 5"); System.out.println("Red = 0 Purple = 1 Pastel = 2 yellow = 3 Orange = 4 Rainbow = 5 "); //Flower which equals user's number pick. number = scan.nextInt(); //Number user picks . random = rand.nextInt(flowerGame.length); //Creates a random index number. Max random number would be max index number. if(number > (flowerGame.length)){ System.out.println("Sorry the number was too high."); } //If user's number is higher than any index number then Exit program. else{ //Opens first else Statement. System.out.println("Please enter how much gold would you like to bet"); bet = scan.nextInt(); /* Takes gold bet */ System.out.println(flowerGame[random]); //Print's flower color. if(random == number){ //If they number picked and index random number were equal doublebet = bet*2; //Multiplies gold bet by 2 System.out.println("You win " + doublebet + " gold!"); //Win message }else{ //If they were not equal System.out.println("You loose."); //You loose } } //Closes first else statement. } //Closes Main method. } //Closes class. Thank's every one who is willing to help.
  2. Thanks! Do you know any website were i could learn those convenctions? Like the letter.equals
  3. //Could some one please tell me why this calculator isn't working? import java.util.Scanner; public class Calcu { public static void main( String[] args ) { Scanner mati = new Scanner(System.in); System.out.println("This program adds up or substracts two numbers"); System.out.println("Enter an operator"); String letter = mati.next(); //WAITS FOR THE PHRASE ADD OR SUBSTRACT System.out.println("Enter your first number"); int userNumberone = mati.nextInt(); // Get's first Number System.out.println("Enter your second number"); int userNumbertwo = mati.nextInt(); //Get's Following Number if(letter == "add") { int result = userNumberone + userNumbertwo; System.out.println(result); } else if(letter == "substract") { int result1 = userNumberone - userNumbertwo; //If statement to add or substract. System.out.println(result1); } } }
×
×
  • Create New...