You would like the user of a program to enter a customer’s last name. Write a statement thaUse the variables k, d, and s so that they can read three different values from standard input--an integer, a float, and a string respectively. On one line, print these variables in reverse order with exactly one space in between each. On a second line, print them in the original order with one space in between them.t asks user "Last Name:" and assigns input to a string variable called last_name.

Respuesta :

Answer:

1st question:

Use the variables k, d, and s so that they can read three different values from standard input an integer, a float, and a string respectively. On one line, print these variables in reverse order with exactly one space in between each. On a second line, print them in the original order with one space in between them.

Solution:

In Python:

k = input()  #prompts user to input value of k i.e. integer value

d = input()  #prompts user to input value of d i.e. float value

s = input()  #prompts user to input value of s i.e. a string

print (s, d, k)  #displays these variable values in reverse order

print (k, d, s)#displays these variable values in original order

In C++:

#include <iostream>    // to use input output functions

using namespace std;   //to identify objects like cin cout

int main() {    //start of main function

  int k;   //declare int type variable to store an integer value

  float d; //  declare float type variable to store a float value

  string s;   //  declare string type variable to store an integer value

  cin >> k >> d >> s;    //reads the value of k, d and s

  cout << s << " " << d << " " << k << endl;     //displays these variables values in reverse order

  cout << k << " " << d << " " << s << endl;   } // displays these variable values in original order

Explanation:

2nd question:

You would like the user of a program to enter a customer’s last name. Write a statement that asks user "Last Name:" and assigns input to a string variable called last_name.

Solution:

In Python:

last_name = input("Last Name:")

# input function is used to accept input from user and assign the input value to last_name variable

In C++:

string last_name;  //declares a string type variable named last_name

cout<<"Last Name: ";  // prompts user to enter last name by displaying this message Last Name:

cin>>last_name; // reads and assigns the input value to string variable last_name

The programs alongwith their outputs are attached.

Ver imagen mahamnasir
Ver imagen mahamnasir

The statement that Use the variables k, d, and s so that they can read three different values from standard input--an integer, a float, and a string respectively and print these variables in reverse order with exactly one space in between each and on a second line, print them in the original order with one space in between them can be represented as follows:

k = int(input("write an integer input: "))

d = float(input("write a float input: "))

s = str(input("write a string input: "))

print(s, d, k)

print(k, d, s)

The code is written in python.

A variable k is declared that prompt the user to input an integer.

A variable d is declared that prompt the user to input a float.

A variable s is declared that prompt the user to input a string.

The variable are printed in reverse order.

The the variables are printed accordingly in the original order.

Note the bolded part of the code are python keywords.

read more: https://brainly.com/question/20709863?referrer=searchResults

Ver imagen vintechnology