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
The goal of an audio codec is
Sloan [31]

If you are looking for what is used for, an audio codec is used for the compression or decompression of digital audio data from a live stream media or an already stored data file.

If you are looking for the purpose, the purpose of using an audio codec is to effectively reduce the size of an audio file without affecting the quality of the sound.

I really hope that this helps you with your question.

7 0
4 years ago
3 component of a computer
madam [21]

Answer:

Hardware

software

Humanware

6 0
4 years ago
Complete main() to read dates from input, one date per line. Each date's format must be as follows: March 1, 1990. Any date not
rewona [7]

Answer:

Explanation:

The following code was written in Java it creates a switch statement for all the month values in order to turn them from Strings into integer values. Then it reads every line of input places them into an array of dates if they are the correct input format, and loops through the array changing every date into the correct output format.Ouput can be seen in the attached picture below.

import java.util.ArrayList;

import java.util.Scanner;

class Brainly {

   public static int intForMonth(String monthString) {

       int monthValue;

       switch (monthString) {

           case "January": monthValue = 1;

               break;

           case "February": monthValue = 2;

               break;

           case "March": monthValue = 3;

               break;

           case "April": monthValue = 4;

               break;

           case "May": monthValue = 5;

               break;

           case "June": monthValue = 6;

               break;

           case "July": monthValue = 7;

               break;

           case "August": monthValue = 8;

               break;

           case "September": monthValue = 9;

               break;

           case "October": monthValue = 10;

               break;

           case "November": monthValue = 11;

               break;

           case "December": monthValue = 12;

               break;

           default: monthValue = 00;

       }

       return monthValue;

   }

   public static void main(String[] args) {

       Scanner scnr = new Scanner(System.in);

       ArrayList<String> dates = new ArrayList<>();

       String date;

       String month;

       String day;

       String year;

       int i = 0;

       while (true) {

           date = scnr.nextLine();

           if (date.equals("-1")) {

               break;

           }

           dates.add(date);

       }

       for (i = 0; i < dates.size(); i++) {

           try {

               month = dates.get(i).substring(0, dates.get(i).indexOf(" "));

               day = dates.get(i).substring(dates.get(i).indexOf(" ") + 1, dates.get(i).indexOf(","));

               year = dates.get(i).substring(dates.get(i).indexOf(",") + 2, dates.get(i).length());

               System.out.println(intForMonth(month) + "/" + day + "/" + year);

           } catch (Exception e) {}

       }

   }

}

8 0
3 years ago
2) A simple operating system supports only a single directory but allows it to have arbitrarily many files with arbitrarily long
puteri [66]

Answer:

Yes it can

Explanation:

The answer is Yes something approximating a hierarchical file system can be simulated. A way to carry out this simulation is through appending to each file name the name of the directory that contains it. But an offside to it is that it may end up becoming too complex to manage because the file name may be too long.

8 0
3 years ago
In the secure development lifecycle, how must the specific security needs of software being developed be defined?- Coding phase
Karo-lina-s [1.5K]

Answer: Requirements phase

Explanation:Requirement phase in the SDL(secure development life-cycle) is the phase where the security is fused with integrity part for any product. This mechanism is done to know about the requirement of the product in the security field. This is done to achieve the completeness in the product and to recover the mistakes that had happened earlier in the product due to security issues.

Other phase given in the option are for making the code, designing the model of product and testing the products aspects respectively.

4 0
3 years ago
Other questions:
  • What the difference between a battery and power supply?
    15·1 answer
  • The internet is a worldwide assembly of computer
    11·1 answer
  • What does the metric column in a routing table do?
    8·1 answer
  • Which of the following is an Example of a technical (“hard”) skill
    6·2 answers
  • Which view in file explorer can use to sort files by column heading
    8·1 answer
  • int sequence[10] = { 3, 4, 5, 6, 7, 8, 9, 10, 1, 2 }; Write a C++ program to ask the user to enter a number, if the number can b
    10·1 answer
  • Pls answer this
    5·1 answer
  • Raman will perform in pune tomorrow(simple past)​
    11·2 answers
  • Parts of a computer software
    12·1 answer
  • Treating others with respect, even when they're impolite, is considered
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!