Skip to content

Instantly share code, notes, and snippets.

@toydotgame
Last active January 30, 2021 01:03
Show Gist options
  • Save toydotgame/c9633f949082acde0e6bde25c8e02562 to your computer and use it in GitHub Desktop.
Save toydotgame/c9633f949082acde0e6bde25c8e02562 to your computer and use it in GitHub Desktop.
Proof of concept.
import java.util.Scanner;
public class percentageCalculator {
public String xStr = "0";
public String yStr = "0";
public static void main(String[] args) {
float x = 0;
float y = 0;
float z = 0;
Scanner scanner = new Scanner(System.in);
System.out.print("Enter a score: ");
x = scanner.nextFloat();
System.out.print("Enter the maximum score: ");
y = scanner.nextFloat();
z = (float) ((x / y) * 100);
System.out.println("You got " + x + "/" + y + ", which is " + z + "%.");
}
}
@toydotgame
Copy link
Author

The floats did take me a long time, though...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment