C++ Saved Program: gifted-palace

facebook share

Here's the online compiler accompanied with IDE at your service. This is a saved code by one of our users. Try it out or save your own from the IDE page and don't forget to leave a feedback. You can find that at the bottom of the page.


import java.util.Scanner;

public class StatsGenerator{
	public static void main(String[] args){
		Scanner input = new Scanner(System.in);


		System.out.print("What level would you like your character to be? ");
		long playerLevel = input.nextInt();
		long Stats = (playerLevel * 3) + 4;

		if (Stats >= 0)
		System.out.println("You have " + Stats + " stat points to spend.\n");
		System.out.print("What would you like your Strength to be? ");
		long str = input.nextInt();
		Stats = Stats - str;
		if (Stats <= 0 || str <= 0){
		System.out.print("Invalid Stats. Please start over.");
		System.exit(0);
	}
		if (Stats >= 0){
		System.out.println("You have " + Stats + " stat points to spend.\n");
	}

		System.out.print("What would you like your Vitality to be? ");
		long vit = input.nextInt();
		Stats = Stats - vit;
		if (Stats <= 0 || vit <= 0){
		System.out.print("Invalid Stats. Please start over.");
		System.exit(0);
	}
		if (Stats >= 0)
		System.out.println("You have " + Stats + " stat points to spend.\n");

		System.out.print("What would you like your Dexterity to be? ");
		long dex = input.nextInt();
		Stats = Stats - dex;
		if (Stats <= 0 || dex <= 0){
		System.out.print("Invalid Stats. Please start over." );
		System.exit(0);
	}
		if (Stats >= 0){
		System.out.println("You have " + Stats + " stat points to spend.\n");
	}

		System.out.print("What would you like your Agility to be? ");
		long agi = input.nextInt();
		Stats = Stats - agi;
		if (Stats < 0 || agi <= 0){
		System.out.print("Invalid Stats. Please start over.");
		System.exit(0);
	}
	System.out.println("We will now calculate your stats.");

	long playerAtk = 150 + (str * 2) + ((int)(dex * 1.5));
	long playerHp = 200 + (playerLevel * 21) + (vit * 14);
	long playerAcc = (50 + (playerLevel) + (dex * 2) /100);
	long playerSpd = 50 + (agi * 3);

	if (playerSpd > 500){
	playerSpd = 500;
}

	System.out.println("You have " + str + " Strength, " + vit + " Vitality, " + dex + " Dexterity, " + agi + " Agility.");

	System.out.println("At level " + playerLevel + " your character has " + playerAtk + " attack.");
	System.out.println("At level " + playerLevel + " your character has " + playerHp + " health.");
	System.out.println("At level " + playerLevel + " your character has " + playerAcc + "% accuracy.");
	System.out.println("At level " + playerLevel + " your character has " + playerSpd + " speed.");


	}
}
Execute

Output

Press the execute button or CTRL + enter to run code.

Inputs