Write a program that asks the user to input their first and last names. The first prompt should state: Please input your first name: The second prompt should state: Please input your last name:

Answers

Answer 1
Answer:

Answer:

Program in c++ and java

Explanation:

C++ Code

#include<iostream> //for input and output  

#include <string>  // for string  

using namespace std;  

int main()  

{  

   string firstname;

string lastname;  

   cout<<"Please input your first name :";

  cin>> firstname;

  cout<<"Please input your last name :";

  cin>> lastname;

   

  cout<< "Your name is "<< firstname << " "<<lastname;

   // declaring output string stream  

 

   return 0;  

}

Java Code

import java.util.Scanner;

public class SquareRoot {

   public static void main(String[] args){

       Scanner scanner = new Scanner(System.in);

       System.out.print("Please enter your first name :");

       String firstName = scanner.next();

       System.out.print("Please enter your last name :");

       String lastname = scanner.next();

       System.out.println("Your name is "+firstName+" "+lastname);

   }

}

Output

Please input your first name :John

Please input your last name :Stone

Your name is John Stone


Related Questions

Search engines enable you to:A. talk to people via the computer.B. locate Web pages related to a specific subject.C. connect to a better ISP.D. find and replace a certain item in Word.
Unplugging a computer can result in the information in what location being lost?A) Floppy disc B) Document Files C) RAM D) NIC
What means that people with disabilities including visual, auditory, physical, speech, cognitive, and neurological disabilities can use the Web? A. CapacityB. Web accessibilityC. Web accessibility initiativeD. Vulnerability
Which of the following decimal (base-10) values is equivalent to the binary (base-2) value 101001?22378241
T/F It is best to write out "greater than" instead of using the symbol > on your PCR

Which one of the following statements is true? a. In one’s complement format, the leftmost bit is saved for the sign where 1 indicates a negative number and 0 indicates a positive number.
b. The smallest integer that can be represented by a sign-and-magnitude binary number is always 0.
c. It is impossible to store 1610 in 4-bits because overflow will occur. d. The two’s complement representation of +6710 in 8-bits is 1000011.

Answers

Answer:

a. In one’s complement format, the leftmost bit is saved for the sign where 1 indicates a negative number and 0 indicates a positive number.

Explanation:

In binary numbers, 1's complement is used to represent the signed binary numbers. In unsigned numbers, there is no need of sign. But in signed binary numbers a signed bit is required. To add the bit that is represent the sign of the number in binary, 0 represents the positive number while 1 represents the negative number.

If we have a number and want to convert it in signed binary number, we just takes it 1's complement and add the signed bit at the left of the number.

E.g.

1 = 0001

is the binary of 1, if we want to add sign, we just add the zero at left most side of the binary which make it positive as given below:

+1 = 0 0001

Now of we want to convert it into negative than, we take 1's complement in which all bits are inverted.

-1 = 1 1110

How to transfer photos from iphone to computer

Answers

If you’re using a Windows computer, the best way to transfer photos from your iPhone to your computer is via USB cable.
First, plug your phone into your computer using the phone’s USB Cable. The Photo app should launch automatically then click the Import button. Check to select the photos you wish to transfer. Once you checked all the photos you wish to transfer, click on Continue. Click Import to start the transfer.

How do you turn your story/script into a rigorous and relevant video project?

Answers

You turn your story into a rigorous and relevant video project by finding a interesting topic, after that you find solid sources to support the topic you picked.

Given a scanner reference variable named input that has been associated with an input source consisting of a sequence of strings and two int variables, count and longest, write the code necessary to examine all the strings in the input source and determine how long the longest string (or strings are). that value should be assigned to longest; the number of strings that are of that length should be assigned to count.

Answers

Answer:

int count = 0;  //int variables

int longest =0;  // int variables

Scanner input = new Scanner(System.in); // given input is reference variable

String str= new String();  // creating object of sting class

while (input.hasNext()) // taking the input by using scanner reference

{

str= input.next();  // taking input in string

if (str.length() == longest) // checking condition

++count;  // increment the count

else

if (Str.length() > longest) // if string is greater then longest

{

longest = str.length(); // calculating length

count = 1;  // assign count to 1

}

}

Explanation:

Following are the description of the code :

  • Declared a two variable count and longest of  int type.
  • Create a object of String class i.e 'str".
  • Taking input in the string by using scanner reference i.e "input".
  • Finally checking the condition of if and else block and calculating the length of string and assign into longest variable.

The code that examines all the strings in the input source and determines how long the longest string (or strings are) is the following:

total = 0;% initial value is zero, in every while loop it will be incremented

while(input.hasNextInt()){

total += input.nextInt( );

}

Which of the following correctly identifies a voltage source and its method of developing electric potential? A. Dry cell—chemical action
B. Generator—genetic action
C. Thermocouple—chemical action
D. Primary cell—heat action on a device

Answers

dry cell chemical action is how it works
Dry cell- Chemical action

I need help with this python exercise:Verify User:

The final listing for remember_me.py assumes either that the user has already entered their username or that the program is running for the first time. We should modify it in case the current user is not the person who last used the program.

Before printing a welcome back message in greet_user(), ask the user if this is the correct username. If it’s not, call get_new_username() to get the correct username.

Also, use a check_username() function to prevent any nested if statements from occurring in greet_user()

Answers

No prob. Let's go over the Python code,

Here's your complete Python program with the added function `check_username()`:

```

import json

filename = 'username.json'

def get_stored_username():

   try:

       with open(filename, 'r') as f:

           username = json.load(f)

   except FileNotFoundError:

       return None

   else:

       return username

def get_new_username():

   username = input("What's your username? ")

   with open(filename, 'w') as f:

       json.dump(username, f)

   return username

def check_username():

   username = get_stored_username()

   if username:

       correct = input(f"Are you {username}? (y/n) ")

       if correct.lower() == 'y':

           return username

   return get_new_username()

def greet_user():

   username = check_username()

   print(f"Welcome back, {username}!")

greet_user()

```

Remember to call `greet_user()` to start the whole shebang. Let me know if anything needs clearing up!