Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.*;
- import java.util.*;
- public class testi1 {
- public static void main( String [ ] args) {
- Scanner lukija;
- lukija = new Scanner(System.in);
- double weight;
- double height;
- double age;
- String Carlicense;
- System.out.print("How much is your weight: ");
- weight = lukija.nextDouble();
- System.out.print ("How much is your height: ");
- height = lukija.nextDoable();
- System.out.print ("How old are you: ");
- age = lukija.nextDouble();
- // 1. Lisää kysely CarLicense muuttujan täyttämiseen
- //esim System.out.print ("Do you have car license? Answer as Yes or No. ");
- // CarLicense = lukija.next();
- //2. Lisää asetetut arvot tulostukseen.
- // System.out.println ("Ikä"+ String.valueOf(age)); <- double tyyppinen muuttuja konvertoidaan string tyyppiseksi, jotta se
- // voidaan tulostaa käyttöliittymälle. CarLicense -muuttuja ei tarvitse konversiota ja sen lisäys
- // olisi seuraavanlainen System.out.println ("Pituus" + CarLicense);
- System.out.println ("Käyttäjän tiedot:");
- System.out.println ("Ikä" );
- System.out.println ("Paino" );
- System.out.println ("Pituus" );
- //3. Korjaa if- lauseen vertailu.
- // if lauseen sulkujen () sisällä täytyy olla vertailu joka on arvoista riippuen tosi tai epätosi.
- // esimerkiksi if (CarLicense =="Yes") <- palauttaa tosi, jos CarLicense:n arvo on Yes
- // saman voi toteuttaa myös käyttämällä Objects.equals(CarLicense, "Yes") -metodia if ehdossa
- // esim if(Objects.equals(CarLicense, "Yes"))
- if (CarLicense("Yes"){
- System.out.printIn("Sinulla on ajokortti: ");
- }else{
- System.out.printIn("Sinulla ei ole ajokorttia: "); }
- System.out.println();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement