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
Alla [95]
4 years ago
15

Create a class called Name that will have three fields first name, middle initial, and last name as parameters. Add a constructo

r to the Name class that accepts a first name, middle initial, and last name as parameters (in that order) and initializes the Name object's state with those values. Write a complete program (i.e. with client class) to check your work. Please submit Name and client class .java files. [10 points]
Computers and Technology
1 answer:
KATRIN_1 [288]4 years ago
7 0

Answer:

The program to the given question can be given as:

Program:

import java.io.*; //import package for client class.

class Name //class-name Name.

{

// data members of the class.

String firstname, middleinitial, lastname;

// define parameterized constructor that would initialize data members

Name(String Fname,String Mname,String Lname)

{

this.firstname= Fname; //Using this key-word for holding value.

this.middleinitial= Mname;

this.lastname= Lname;

}

void showtime() //method showname with no return-type.

{

//define variable name for strore value.

String name;

name = firstname + " " + middleinitial + " " + lastname;

System.out.print(name); //print value.

}

}

class Main //main class

{

public static void main (String[] args) //main method.

{

Name ob =new Name("AAA","BBB","CCC");

//creating class object.and passing value to parameterized constructor.

ob.showtime();

//calling showtime function.

}

}

Output:

AAA BBB CCC.

Explanation:

The explanation of the program can be given as:

In this program, we create a class i.e. (Name). In class, we declare a variable that's data type is String because It is a sequence of characters that hold a string value. Then we define the parameterized constructor. It is used for holding string values in it. We define a function i.e. showtime. This function is used for string value that is passed in the constructor. Then we create the main class that has the main method. It is used for calling the Name class by creating its object. After creating a name class object we pass the value to the parameterized constructor. and call the function, Where it is a function that doesn't have any return type.

You might be interested in
How can learning opportunities for AI be extended to all
statuscvo [17]

Answer:

Learning opportunities for AI can be extended to all through the inclussion of courses and different teaching methods related to Artificial Intelligence, new technologies, computer science, programming and, in short, everything related to the digital world, in the educational plans at the national level. This is so because artificial intelligence and computer systems are the basis for the development of the new tools jobs of tomorrow. Thus, education in these subjects is essential so that citizens can enter the labor market once they acquire the necessary age, having the knowledge to do so in a proper way.

6 0
3 years ago
What function(s) does an interpreter perform with the instructions in a high-level programming language?
allochka39001 [22]

Answer:

Translates and Executes.

Explanation:

5 0
3 years ago
Visual Basics: 1 ) Write an if/else statement that compares the double variable pH with 7.0 and makes the following assignments
Lemur [1.5K]

Answer:

visual basic: 1)

Module PHmodule

   Sub Main()

       'Creating a variable for each entity

       dim ph as double = 0.0, neutral,base,acid as boolean

       'Writing a line to show user what to do

       console.writeline("Enter the pH :")

       'Taking the value

       ph=console.readline()

       'using if & elseif statement for distingushing the values into correct catagories

       if ph<7.0 then

       neutral=false:base=false:acid=true

       elseif ph>7.0 then  

       neutral=false:base=true:acid=false

       elseif ph=7.0 then

       neutral=true:base=false:acid=false

       end if

       'Printing the result

       console.writeline(" Neutral :" & Neutral)

       console.writeline(" base :" & base)

       console.writeline(" acid :" & acid)

       'command for staying in the command prompt for reading the result

       console.readline()

   End Sub

End Module

visual basic: 2)

Module AGEmodule()

  Sub Main()

       'Creating a variable for each entity

       dim age,minors,adults,seniors as integer = 0

       'Taking age from user

       console.writeline("Enter the age")

       age=console.readline()

       'using if & elseif statement for checking the age differnce

       if age<18 then'

       minors +=1

       else if age>18 and age<64 then

       adults +=1

       else if age>64 then  

       seniors +=1

       end if

       'printing result

       console.writeline("minors="&minors)

       console.writeline("adults="&adults)

       console.writeline("seniors="&seniors)

       'command for reading the result  

       console.readline()

  End Sub

End Module

Explanation:

visual basic 1) it is very simple program which allow us to find if the substance is acidic, basic or neutral. we use sim statement for making a variable as double (gives value in decimal) which allow to take a value from the user through console.readline() command and then by using the if statement we apply the condition if the ph is less then, greator then or equal to 7.0 value. thus the program gives us the answer. console.writeline() command is used to print a command on the screen while console.readline() command let us read the lines until we press enter.

visual basic 2)a program which allow us to count and add number of persons according to their age. we use dim statement for creating the variable as integers in which we take the age from user and then after checking it through if statement we increment according to three categories i.e. minors, adults, seniors. the console.writeline() command allow us to print anything on screen and console.readline() allowus to take value while compiling.

thank you...

6 0
4 years ago
Winners announced tomorrow when I check results ngl I gtg to sleep soon I should see a lot of people tomorrow ^^
kobusy [5.1K]

i am sup by the way. so im guessing i win?

4 0
3 years ago
What is the output for the following program?
Lelu [443]

Answer:

Output:

15

20

25

Explanation:

In first iteration value of num is 10. Condition is checked 10 is less than 21 so value of num is incremented by 5 and value 15 is printed than again condition is checked 15<21 so value of num is incremented again and 20 is printed. Again condition is checked 20<21. So 25 is printed. Then 4th time when condition is checked vakue of num is 25 and while loop condition becomes false because 25 is not less than 21 and program is terminated here.

6 0
3 years ago
Other questions:
  • major m,ajorrr points helpppppppppppppppppppppppppppi have a question i hit a few buttons and now my computer is saying everythi
    11·2 answers
  • The calls radioed to patrol officers, or assignments given to police patrol units by 911 dispatchers, reveal the types of proble
    9·1 answer
  • Load the titanic sample dataset from the Seaborn library into Python using a Pandas dataframe, and visualize the dataset. Create
    10·1 answer
  • The speed of sound depends on the material the sound is passing through. Below is the approximate speed of sound (in feet per se
    9·1 answer
  • True or False: It is illegal to park in a location that you block or create a hazard for other vehicles.
    11·2 answers
  • There are many modes of remote visual communication. which is the most common mode
    5·1 answer
  • What is the output of the C++ codeabove?
    14·1 answer
  • Greg works outside. He is often found cutting grass and making the local park grounds look nice for guests.
    10·1 answer
  • Difine Mainframe Computer~<br><br><br><br><br><br><br><img src="https://tex.z-dn.net/?f=%20%5C%3A%20%20%5C%3A%20" id="TexFormula
    12·2 answers
  • Network forensic analysis. A network forensic analyst is responsible for identifying worms, viruses, and infected nodes in the c
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!