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
IrinaVladis [17]
3 years ago
6

Write a method called processName that accepts a Scanner for the console as a parameter and that prompts the user to enter his o

r her full name, then prints the name in reverse order (i.e., last name, first name). You may assume that only a first and last name will be given. You should read the entire line of input at once with the Scanner and then break it apart as necessary. Here is a sample dialogue with the user:
Output:Please enter your full name: Sammy JankisYour name in reverse order is Jankis, Sammywhat I have:public static void processName(Scanner in){System.out.print("Please enter your full name: ");String Name = in.nextLine();String lastName= in.subString(6,11);String firstName= in.subString(0,5);System.out.println("Your name in reverse order is " + lastName + ", " + firstName);}
Computers and Technology
1 answer:
ANEK [815]3 years ago
6 0

Answer:

Complete definition of method processName is as follows:

public static void processName(Scanner in){

   System.out.println("Please enter your full name: ");

   String Name = in.nextLine();

   String [] strings = Name.split(" ");

String firstName = strings[0];

String lastName = strings[1];

System.out.println("Your name in reverse order is " + lastName+ " "+ firstName);

}

Explanation:

Here subString method is not useful to break the string into first name and last name.

The better idea is to use the spilt(); function of string. split() function is used to split the given string into two halves depending on the delimiter passed as argument.

In the above method blank space (" ") is passed as delimiter. Thus split function stores the first half of string before blank space in strings array at location 0 and 1 respectively.

Sample program to implement above method:

import java.util.Scanner;

public class Main{

   public static void main(String [] args)

   {

       Scanner in = new Scanner(System.in);

       processName(in);

   }

   public static void processName(Scanner in){

   System.out.println("Please enter your full name: ");

   String Name = in.nextLine();

   String [] strings = Name.split(" ");

String firstName = strings[0];

String lastName = strings[1];

System.out.println("Your name in reverse order is " + lastName+ " "+ firstName);

   

}  

}

Sample output:

Please enter your full name:  

Jim hoppers

Your name in reverse order is hoppers Jim

You might be interested in
CHALLENGE
Lorico [155]

Answer:

Following are the program to this question:

#include <stdio.h>//using the header file

int main()//main method

{

int y;//defining integer variable y

printf("Enter year value:");//print message

scanf("%d", &y);//use input method for input year value

if (y>= 2101)//defining if block that checks year greater then 2101

   printf("Distant future");//print message

else if (y>= 2001)//defining else if block that checks year greater then 2001

   printf("21st century"); //print message

else if (y>= 1901)//defining else if block that checks year greater then 1901

   printf("20th century");//print message

else  //defining else block

   printf("Long ago");//print message

   return 0;

}

Output:

Enter year value:1998

20th century

Explanation:

In the given C language code, inside the main method, an integer variable "y" is defined, which allows the user to input the year value, and use the multiple conditions to check the given value and print message when the condition is matched.  

  • Inside the "if" condition block, it checks the "y" variable value is greater and equal to 2101. so, it will print "Distant future", otherwise go to the next condition.
  • In this, if "y" value is greater than equal to "2001", it will print the message "21st century", otherwise go to the next condition.  
  • In this, If the value of "y" is greater than equal to "1901", it will print the message "20th century", and if all the above condition is not true, then it will go to the else block, and it will print "Long ago" as the message.
6 0
3 years ago
2. A well designed high-volume system will minimize _________ inventory and reduce _____________for the product or service. a) w
valina [46]

Answer:

A.

Explanation:

A well designed high-volume system will minimize work-in-process (WIP) inventory and reduce lead time for the product.

Work in process (WIP) are partially finished products. WIP inventory could be minimized by designing a suitable high-volume system.

Lead time or throughput time is the time taken for a product to be manufactured or processed. A well designed high-volume system would reduce throughput time.

7 0
3 years ago
Nora has shared a document with others, and she needs to be able to easily identify when others are modifying the
Lilit [14]

Answer:

What is the purpose of the wordart text effect called Transform?

What is the purpose of the WordArt text effect called Transform? It adjusts the shape of the text. Why is it helpful to combine documents when there are multiple reviewers? This allows users to view color-coded changes from several reviewers in one document.

Explanation:

8 0
3 years ago
An organization is assigned a Class-C network 200.120.80.0 and wants to form subnets for its threedepartments: D1 (60hosts), D2
Nataliya [291]

Answer:

D1= 60 HOSTS

network address - 200.120.80.64/26

subnet mask -255.255.255.192/26

D2 = 90 HOSTS

network address - 200.120.80.0/25

subnet mask -255.255.255.128/25

D3 = 90 HOSTS

network address - 200.120.80.128/25

subnet mask -255.255.255.128/25

5 0
4 years ago
Write a program to implement the algorithm that you designed in Exercise 21 of Chapter 1. Your program should allow the user to
Murrr4er [49]

Answer:

total = 0

items = int(input("Enter the number of items ordered: "))

for i in range(items):

   price = float(input("Enter the price of item " + str(i+1) + ": "))

   total += price

if total < 200:

   total += (items * 10)

   

print("Bill is $" + str(total))

Explanation:

*The code is in Python.

Ask the user to enter the number of items ordered

Create a for loop that iterates depending on the number of items ordered. Inside the loop, ask the price of each item and add it to the total

After the loop, check the total. If it is smaller than 200, add 10 for each item to the total

Print the total

4 0
4 years ago
Other questions:
  • A(n) ________ network is a computer network that spans a relatively small area, allowing all computer users to connect with each
    14·1 answer
  • Andy uses a dial-up modem to connect to the Internet. He usually browses news sites, but he notices that online video takes a lo
    6·2 answers
  • The array index can be any nonnegative integer less than the array size.
    10·1 answer
  • Create a lottery game application. Generate three random numbers (see Appendix D for help in doing so), each between 0 and 9. Al
    14·1 answer
  • How do you represent the decimal integer 50 in binary?
    14·1 answer
  • Identify a stressor in your life. Conduct an internet search to locate at least two reliable sources of information on effective
    6·1 answer
  • William created a spreadsheet and he would like to enter the data he collected. What information should he put in the first row?
    15·1 answer
  • WHAT ARE THE RISK OF DUST​
    15·1 answer
  • PC GAMER HELP!<br><br> What is -everything- I need to have a -GOOD- gaming area for a pc gamer?
    7·1 answer
  • Difference between batabse and database management system
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!