Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class ThroughTheHaywireCalledAsJava {
- public static void main(String[] args) {
- //1-es
- String Example = "Adios muchachos!";
- System.out.println(Example);
- //2-es
- int InputNumber =5;
- if (InputNumber == 1 || InputNumber == 2 || InputNumber ==12)
- {
- System.out.println("Tél");
- }
- if (InputNumber == 3 || InputNumber == 4 || InputNumber == 5)
- {
- System.out.println("Tavasz");
- }
- if (InputNumber == 6 || InputNumber == 7 || InputNumber == 8)
- {
- System.out.println("Nyár");
- }
- if (InputNumber == 9 || InputNumber == 10 || InputNumber == 11)
- {
- System.out.println("Ősz");
- }
- switch (InputNumber)
- {
- case 12:
- case 1:
- case 2: System.out.println("Tél");
- break;
- case 3:
- case 4:
- case 5: System.out.println("Tavasz");
- break;
- case 6:
- case 7:
- case 8: System.out.println("Nyár");
- break;
- case 9:
- case 10:
- case 11: System.out.println("Ősz");
- break;
- default:
- break;
- }
- //3-as
- for (int i = 1; i < 11; i++){
- for (int j = 1; j <= i; j++){
- System.out.print(i*j + "\t");
- }
- System.out.println();
- }
- //5-ös
- int[] ExampleLine = {1245, 8525, 12, 45, 36954,
- 457, 336, 96, 558, 10};
- int smallest = ExampleLine[0];
- for (int i = 1; i < 10; i++){
- if (smallest> ExampleLine[i]){
- smallest = ExampleLine[i];
- }
- }
- System.out.println ("A legkisebb: " + smallest);
- int largest = ExampleLine[0];
- for (int i = 1; i < 10; i++){
- if (largest < ExampleLine[i]){
- largest = ExampleLine[i];
- }
- }
- System.out.println ("A legnagyobb: " + largest);
- for (int i = 0; i < 9; i++){
- for (int j = i; j <10; j++){
- if (ExampleLine[i] > ExampleLine [j]){
- int temp = ExampleLine[i];
- ExampleLine[i] = ExampleLine[j];
- ExampleLine[j] = temp;
- }
- }
- }
- System.out.print("A tömb elemei:\t");
- for (int i = 0; i < 10; i++){
- System.out.print(ExampleLine[i] + "\t");
- }
- System.out.println ();
- //6-os
- int[] Radii = { 4, 5, 8};
- double pi = 3.14;
- for (int i = 0; i < 3; i++){
- System.out.println ("A kör sugara: " + Radii[i] + ", területe: " + Radii[i]*pi*Radii[i]);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement