Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Main {
- public static void main(String[] args) {
- System.out.println("------------------4---------------------------");
- int wynik = 0;
- String str;
- int size;
- Scanner klawiatura = new Scanner(System.in);
- System.out.print("Wpisz liczbe: ");
- str = klawiatura.nextLine();
- size = str.length();
- System.out.println("Ilosc liczb w ciągu: " + size);
- char[] podzielone = str.toCharArray();
- for(int i=0; i<size; i++){
- int x = Character.getNumericValue(podzielone[i]);
- wynik = wynik + x;
- }
- System.out.println("Suma wpisanej liczby to: " + wynik);
- System.out.println("--------------------5-----------------------");
- Scanner klawiaturaa = new Scanner(System.in);
- System.out.print("Wpisz liczbe: ");
- double liczba = klawiaturaa.nextDouble();
- double x = liczba - Math.floor(liczba);
- if(x >= 0.5){
- System.out.println("Liczba zaokrąglona: " + Math.ceil(liczba));
- } else {
- System.out.println("Liczba zaokrąglona: " + Math.floor(liczba));
- }
- System.out.println("--------------------6-----------------------");
- Scanner klawiaturaaa = new Scanner(System.in);
- System.out.print("Wpisz pierwsza liczbe: ");
- int liczbaa = klawiaturaaa.nextInt();
- System.out.print("Wpisz drugą liczbe: ");
- int liczbaaa = klawiaturaaa.nextInt();
- int calosc = liczbaa/liczbaaa;
- int reszta = liczbaa%liczbaaa;
- if(reszta >0){
- System.out.println("Wynik to: " + calosc + "." + reszta);
- } else {
- System.out.println("Wynik to: " + calosc);
- }
- System.out.println("--------------------7-----------------------");
- Scanner klawiaturaaaa = new Scanner(System.in);
- System.out.print("Wpisz ile sekund temu słyszałeś uderzenie pioruna: ");
- float liczbaaaa = klawiaturaaaa.nextFloat();
- float blyskawica = liczbaaaa * 330;
- System.out.println("Wyładowanie atmosferyczne bylo oddalone od Ciebie o: " + blyskawica + " metrów:");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement