Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- package bruch;
- import java.util.Scanner;
- /**
- *
- * @author LipplDom
- */
- public class Bruch {
- /**
- * @param args the command line arguments
- */
- public static void main(String[] args) {
- int oben, unten, teiler = 0;
- Scanner s = new Scanner(System.in);
- System.out.println("Bruch oben:");
- oben = s.nextInt();
- System.out.println("Bruch unten:");
- unten = s.nextInt();
- if (oben < unten) {
- teiler = oben;
- } else {
- teiler = unten;
- }
- while (oben % teiler != 0 || unten % teiler != 0) {
- teiler -= 1;
- }
- oben = oben / teiler;
- unten = unten / teiler;
- System.out.println(oben + "/" + unten);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement