Giter VIP home page Giter VIP logo

laboratorjava's Introduction

import javax.swing.JOptionPane;

public class RandomGuess { public static void main(String[] args) { // Solicităm utilizatorului să-și gândească un număr între 1 și 10 String input = JOptionPane.showInputDialog("Gândește-ți un număr între 1 și 10 și apasă OK.");

    // Generăm un număr aleatoriu între 1 și 10
    int randomNumber = 1 + (int) (Math.random() * 10);

    // Convertim răspunsul utilizatorului într-un număr întreg
    int userGuess = Integer.parseInt(input);

    // Afișăm numărul generat aleatoriu și dacă utilizatorul a ghicit sau nu
    JOptionPane.showMessageDialog(null, "Numărul generat este: " + randomNumber + "\n" +
            (userGuess == randomNumber ? "Ai ghicit! Bravo!" : "Nu ai ghicit. Mai încearcă!"));
}

}

// PROBLEMA 2

public class CarlysMotto { public static void main(String[] args) { String motto = "Carly’s makes the food that makes it a party."; System.out.println(motto); } }

public class CarlysMotto2 { public static void main(String[] args) { String motto = "Carly’s makes the food that makes it a party."; int length = motto.length();

    // Afișăm un rând de steluțe deasupra și sub motto
    for (int i = 0; i < length + 4; i++) {
        System.out.print("*");
    }
    System.out.println();

    // Afișăm motto-ul înconjurat de steluțe
    System.out.println("* " + motto + " *");

    // Afișăm un rând de steluțe deasupra și sub motto
    for (int i = 0; i < length + 4; i++) {
        System.out.print("*");
    }
    System.out.println();
}

}

// PROBLEMA 3

public class SammysMotto { public static void main(String[] args) { String motto = "Sammy’s makes it fun in the sun"; System.out.println(motto); } }

public class SammysMotto2 { public static void main(String[] args) { String motto = "Sammy’s makes it fun in the sun"; int length = motto.length();

    // Afișăm o linie de caractere 'S' deasupra și sub motto
    for (int i = 0; i < length + 4; i++) {
        System.out.print("S");
    }
    System.out.println();

    // Afișăm motto-ul înconjurat de caractere 'S'
    System.out.println("S " + motto + " S");

    // Afișăm o linie de caractere 'S' deasupra și sub motto
    for (int i = 0; i < length + 4; i++) {
        System.out.print("S");
    }
    System.out.println();
}

}

laboratorjava's People

Contributors

botcseke avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.