SHOW:
|
|
- or go back to the newest paste.
| 1 | /** | |
| 2 | * | |
| 3 | */ | |
| 4 | ||
| 5 | /** | |
| 6 | * TODO Kort beskrivning av klassen | |
| 7 | * @author Filip Berndtsson, ifiebo-1 | |
| 8 | */ | |
| 9 | ||
| 10 | ||
| 11 | import java.util.Scanner; | |
| 12 | public class inlämning5 | |
| 13 | {
| |
| 14 | private static Scanner keyboard = new Scanner(System.in); | |
| 15 | ||
| 16 | ||
| 17 | /** | |
| 18 | * @param args | |
| 19 | */ | |
| 20 | public static void main(String[] args) | |
| 21 | {
| |
| 22 | ||
| 23 | // TODO Auto-generated method stub | |
| 24 | ||
| 25 | } | |
| 26 | public static float area(int radius) | |
| 27 | {
| |
| 28 | ||
| 29 | int radie = 0; | |
| 30 | float arean = 0; | |
| 31 | float kvadratRadie = 0; | |
| 32 | float basArea = 0; | |
| 33 | ||
| 34 | ||
| 35 | System.out.print("Vad är Radien för basen? ");
| |
| 36 | radie = keyboard.nextInt(); | |
| 37 | kvadratRadie = (int) Math.pow( radie, 2); | |
| 38 | basArea = (float) (kvadratRadie * Math.PI); | |
| 39 | return basArea; | |
| 40 | } | |
| 41 | public static double area(int radius, int height) | |
| 42 | {
| |
| 43 | ||
| 44 | int radie = 0; | |
| 45 | int hojd = 0; | |
| 46 | float mantelytansArea = 0; | |
| 47 | ||
| 48 | System.out.print("Vad är Radien för basen? ");
| |
| 49 | radie = keyboard.nextInt(); | |
| 50 | ||
| 51 | ||
| 52 | mantelytansArea = (float)Math.PI * radie * (pythagoras(radie, hojd)); | |
| 53 | ||
| 54 | return mantelytansArea; | |
| 55 | ||
| 56 | ||
| 57 | } | |
| 58 | public static float pythagoras(int sidaA, int sidaB) | |
| 59 | {
| |
| 60 | ||
| 61 | int Sida1; | |
| 62 | int Sida2; | |
| 63 | float hypotenusanC = 0; | |
| 64 | System.out.print("Skriv in ett värde för sida 1: ");
| |
| 65 | Sida1 = keyboard.nextInt(); | |
| 66 | ||
| 67 | hypotenusanC = (float) Math.sqrt((float) Math.pow(Sida1, 2) + Math.pow(Sida2, 2)); | |
| 68 | return hypotenusanC; | |
| 69 | ||
| 70 | } | |
| 71 | public static float volume(int radius, int height) | |
| 72 | {
| |
| 73 | int radie; | |
| 74 | int hojd; | |
| 75 | float volym; | |
| 76 | volym = (float) ((Math.PI * (radie * radie ) * hojd ) / 3); | |
| 77 | return volym; | |
| 78 | ||
| 79 | } | |
| 80 | public static int[] fraction(int nominator, int denominator) | |
| 81 | {
| |
| 82 | int[] fraktion = new int[3]; | |
| 83 | int taljare; | |
| 84 | int namnare; | |
| 85 | System.out.print("Skriv in ett värde för täljaren: ");
| |
| 86 | taljare = keyboard.nextInt(); | |
| 87 | System.out.print("Skriv in ett värde för nämnaren: ");
| |
| 88 | namnare = keyboard.nextInt(); | |
| 89 | ||
| 90 | fraktion[0] = taljare / namnare; | |
| 91 | fraktion[1] = taljare % namnare; | |
| 92 | fraktion[2] = namnare; | |
| 93 | return fraktion; | |
| 94 | ||
| 95 | } | |
| 96 | ||
| 97 | public static int sgd(int a, int b) | |
| 98 | ||
| 99 | {
| |
| 100 | int braktalA; | |
| 101 | int braktalB; | |
| 102 | ||
| 103 | System.out.print("Skriv in ett värde för A: ");
| |
| 104 | ||
| 105 | if (braktalA == 0) | |
| 106 | {
| |
| 107 | return braktalB; | |
| 108 | } | |
| 109 | return sgd(braktalB % braktalA, braktalA); | |
| 110 | } | |
| 111 | ||
| 112 | public static int print(int[] delar) | |
| 113 | {
| |
| 114 | delar = new int[3]; | |
| 115 | ||
| 116 | delar[0] = keyboard.nextInt(); | |
| 117 | delar[1] = keyboard.nextInt(); | |
| 118 | delar[2] = keyboard.nextInt(); | |
| 119 | if(delar[0] == 0) | |
| 120 | {
| |
| 121 | return delar[1]; | |
| 122 | return delar[2]; | |
| 123 | } | |
| 124 | if (delar[1] == 0) | |
| 125 | {
| |
| 126 | return delar[0]; | |
| 127 | } | |
| 128 | if (delar[2] == 0) | |
| 129 | {
| |
| 130 | return 0; | |
| 131 | } | |
| 132 | ||
| 133 | } | |
| 134 | ||
| 135 | } |