Last active
January 30, 2021 01:03
-
-
Save toydotgame/c9633f949082acde0e6bde25c8e02562 to your computer and use it in GitHub Desktop.
Proof of concept.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 + "%."); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The floats did take me a long time, though...