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
Fed [463]
4 years ago
11

CHALLENGE ACTIVITY 2.15.1: Reading and outputting strings. Write a program that reads a person's first and last names, separated

by a space. Then the program outputs last name, comma, first name. End with newline. Example output if the input is: Maya Jones Jones, Maya.
Computers and Technology
1 answer:
dlinn [17]4 years ago
8 0

Answer:

Following are the program in Java language

import java.util.*; // import package

public class Main  // main function

{

public static void main(String[] args)  // main class

{

    String l_name,f_name; // variable declaration

    Scanner sc6=new Scanner(System.in); // scanner class

   f_name= sc6.next(); // Read input

 l_name=sc6.next(); // Read input

 System.out.print(l_name); // display last name

  System.out.print(","); // display comma

   System.out.println(f_name); // display first name

}

}

Output:

Maya Jones

Jones, Maya

Explanation:

Following are the description of program

  • Declared a variable  'l_name","f_name" as the string type .
  • Create the instance of scanner class i.e "sc6".
  • Read the user input by using the instance "sc6" of the scanner class in the variable "l_name" and "f_name ".
  • Finally by system.print() method we will display the value according to the format in the given question .

You might be interested in
Input header here<br>input paragraph 1 here
konstantin123 [22]

Answer:

The <input> HTML element is used to create interactive controls for web-based forms in order to accept data from the user; a wide variety of types of input data and control widgets are available, depending on the device and user agent. The <input> element is one of the most powerful and complex in all of HTML due to the sheer number of combinations of input types and attributes.

Explanation:

3 0
3 years ago
Write a program that uses a stack to test input strings to determine whether they are palindromes. A palindrome is a sequence of
Maslowich

Answer:

Here the code is given as follows,

Explanation:

def isPalindrome(x):

   stack = []

   #for strings with even length

   if len(x)%2==0:

       for i in range(0,len(x)):

           if i<int(len(x)/2):

               stack.append(x[i])

           elif stack.pop()!=x[i]:

               return False

       if len(stack)>0:

           return false

       return True

   #for strings with odd length    

   else:

       for i in range(0,len(x)):

           if i==int(len(x)/2):

               continue

           elif i<int(len(x)/2):

               stack.append(x[i])

           elif stack.pop()!=x[i]:

               return False

       if len(stack)>0:

           return false

       return True  

def main():  

   while True:  

       string = input("Enter a string or Return to quit: ")  

       if string == "":  

           break  

       elif isPalindrome(string):  

           print("It's a palindrome")  

       else:  

           print("It's not a palindrome")  

if __name__ == '__main__':  

   main()

8 0
3 years ago
ASAP!!!!!!!
Sidana [21]
A .2:)())...........\\
5 0
3 years ago
Read 2 more answers
Which task can be completed using the Export File menu?
VMariaS [17]

Answer:

You can export files!

6 0
4 years ago
Ayuda pliz es para ya!!!!!<br> nesesito un codigo html que me muestre este texto
BartSMP [9]
Sorry I don’t understand your language I wish I could help you but I just don’t understand

3 0
3 years ago
Other questions:
  • to create an app for a mobile device, yourself, you would use BLANK software like Swift, Corona or Scratch.
    13·1 answer
  • The icacls.exe command adds __________, which are visible by clicking the Advanced button in the folder Properties dialog box
    15·1 answer
  • Templates allow for the quick creation of _____.
    7·1 answer
  • When would an absolute cell reference be most helpful?
    12·2 answers
  • Alto Innovations creates custom software for organizations. The company's managers want to build a high-performance culture in t
    11·1 answer
  • Anyone know the name of this font? and what site i can find it on so i can type it????
    8·1 answer
  • What does "scanf(\"%d\" mean?
    13·2 answers
  • When an instruction is sent to the CPU in a binary pattern, how does the CPU know what instruction the pattern means
    7·1 answer
  • You have recently subscribed to an online data analytics magazine. You really enjoyed an article and want to share it in the dis
    9·1 answer
  • Can someone be my friend,don't friend me until i ask you Questions
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!