1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Delicious77 [7]
3 years ago
9

As a twist on the Hello World exercise, you are going to be the end user of the Hello class. This class is designed to greet the

user in a variety of world languages. For this task, complete the following:
Use the Scanner class to ask the user for their name.
Create a Hello object by passing the name to the constructor.
Call at least 3 methods from the Hello class to print the greeting in 3 different languages.
Remember to write your code in the HelloTester class, but make sure you take a look at the Hello class so that you know the names of the methods you need to use.

Computers and Technology
1 answer:
Flura [38]3 years ago
4 0

Answer:

Here is the Hello class:

public class Hello { //class name

     private String name; //to store the name

     

      public Hello (String names) //parameterized constructor

      { name = names;  }  

     

      public void English() { //method to greet user in english

           System.out.print("Hello "); //displays Hello on output screen

           System.out.print(name); //displays user name

           System.out.println("!");  }  //displays exclamation mark symbol

           

           public void Spanish(){ //method to greet user in spanish

               System.out.print("Hola "); //displays Hello on output screen

               System.out.print(name); //displays user name

               System.out.println("!"); } //displays exclamation mark symbol

           

         public void French() { //method to greet user in french

              System.out.print("Bonjour "); //displays Hello on output screen

              System.out.print(name);  //displays user name

              System.out.println("!");  } } //displays exclamation mark symbol

           

Explanation:

Here is the HelloTester class:

import java.util.Scanner; //to accept input from user

public class HelloTester { //class name

 public static void main (String[]args)  { //start of main method

String name; //to store the name of user

Scanner input = new Scanner(System.in);  //creates Scanner class object

System.out.println("Enter name?" );  //prompts user to enter name

 name = input.nextLine(); //scans and reads the name from user

 Hello hello = new Hello(name); //creates Hello class object and calls constructor by passing name

hello.English(); //calls English method using object hello to greet in english

hello.Spanish(); //calls Spanish method using object hello to greet in spanish

hello.French(); } }  //calls French method using object hello to greet in french

The output of the program is:

Enter name?                                                                                                                    user                                                                                                                           Hello user!                                                                                                                    Hola user!                                                                                                                    Bonjour user!  

The screenshot of the program along with its output is attached.

You might be interested in
6.What does transgenic mean?​
bearhunter [10]

answer:

transgenic means that one or more DNA sequences from another species have been introduced by artificial means.

explanation:

  • transgenic plants can be made by introducing foreign DNA into a variety of different tissues
  • transgenic mice are one of the most common animal models used
6 0
3 years ago
Read 2 more answers
In procedural programming, where does the flow of control usually route from the main function?
Zinaida [17]

Answer:

Subroutine or called function.

Explanation:

Procedural programming is a programming techniques of creating modular divisions between lines of code, with a provision to call and run a block of code at any given instance in the program.

A program flow control breaks at will from the main function to a target defined function or subroutine, which returns a value back to the normal flow of the program. It uses conditional and loop statement to achieve its task.

6 0
3 years ago
Which technology has the potential to be misused to make atomic bombs? A. computer technology B. nuclear technology C. medical t
Tcecarenko [31]

Answer:

B) Nuclear Technology

Explanation:

Nuclear technology involves atomic nuclei reactions which are used to generate energy. The product of nuclear reactions has huge advantages in Medicine, Agriculture, power generation, Water Desalination etc. However This technology can be misused to produce nuclear bombs (atomic bombs) Which are very dangerous weapons of mass destruction.

Since nuclear reactions involve chain (continous) reactions, they effective damage of detonating a nuclear bomb is huge.

4 0
4 years ago
Which situation can result in positive population growth?
Solnce55 [7]
A massive ammount of crop growth.
7 0
3 years ago
Easter Sunday is the first Sunday after the first full moon of spring. To compute the date, you can use this algorithm, invented
BlackZzzverrR [31]

Answer:

The program written in Java without comment is as follows

import java.util.*;

public class MyClass {

   public static void main(String args[]) {

       Scanner input = new Scanner(System.in);

       System.out.print("Year: ");

       int y = input.nextInt();

       int a = y%19;

       System.out.println("a = "+a);

       int b = y / 100;

       System.out.println("b = "+b);

       int c = y%100;

       System.out.println("c = "+c);

       int d = b / 4;

       System.out.println("d = "+d);

       int e = b%4;

       System.out.println("e = "+e);

       int g = (8 * b + 13)/25;

       System.out.println("g = "+g);

       int h = (19 * a + b - d - g + 15)%30;

       System.out.println("h = "+h);

       int j = c/4;

       System.out.println("j = "+j);

       int k = c%4;

       System.out.println("k = "+k);

       int m = (a + 11 * h)/319;

       System.out.println("m = "+m);

       int r = (2 * e + 2 * j - k - h + m + 32)%7;

       System.out.println("r = "+r);

       int n = (h - m + r + 90)/25;

       System.out.println("n = "+n);

       int p = (h - m + r + n + 19)%32;

       System.out.println("p = "+p);

   }

}

Explanation:

<em>I've added the full source code as an attachment where I use comments to explain difficult lines</em>

Download java
7 0
4 years ago
Other questions:
  • What is the operating system?
    9·1 answer
  • The part of the computer that contains the brain, or central processing unit, is also known as the
    15·1 answer
  • We already know that we can create a lunar lander application of the pipe-and-filter architecture style from three independent J
    6·1 answer
  • Which statements accurately describe the Bookmark feature in the Audio/Video control bar? Check all that apply.
    13·1 answer
  • Which K-Drama was made in 2009?
    5·2 answers
  • Which of the following is another type of brake system used in trucks
    5·1 answer
  • Fill in the blanks Pasaline could ----- and ------- very easily.​
    8·1 answer
  • Your company is a small start-up that has leased office space in a building shared by other businesses. All businesses share a c
    6·1 answer
  • All the network nodes are connected to each other
    8·1 answer
  • 2. How does the internet give us the ability to communicate?
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!