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
Katena32 [7]
3 years ago
11

Write a program that does the following:

Computers and Technology
1 answer:
Nataly_w [17]3 years ago
8 0

Answer:

Following is the program in Java language:

import java.util.*;//import package

public class Main // main class

{

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

{

    String  firstname,lastname; // Declare the two String variables

    Scanner ob=new Scanner(System.in); // create a object of scanner //class

    System.out.println("Enter the first name:");  // Prompt the user for // enter the first name

   firstname=ob.nextLine();// Read in the first name by user

    System.out.println("Enter the last name:"); // Prompt the user for last //name

   lastname=ob.nextLine();// Read in the last name by user

   System.out.println("Hello " + firstname +' ' +lastname); // print the //firstname,lastname

}

}

Output:

Enter the first name:

San

Enter the last name:

ert

Hello San ert

Explanation:

Following are the description of program

  • Declared two variable of string type i.e "firstname"  and "lastname".
  • Create a instance or object  of scanner class .i.e "ob".
  • Prompt the user to enter the first name in the  "firstname" variable
  • Read in the first name by the user by using the method nextLine() in the first name variable
  • Prompt the user to enter the  last name.
  • Read in the last name by the user by using the method nextLine() in the lastname variable.
  • Finally, print the first name and last name.

You might be interested in
Write a program that computes the monthly net pay of the employee for a steel factory. The input for this program is the hourly
Mars2501 [29]

Answer:

#include<stdio.h>

int main()

{

float rate_of_pay,regular_hours,overtime_hours,grosspay,netpay,tax;

printf("Enter the Hourly rate of pay : ");

scanf("%f",&rate_of_pay);

printf("Enter the number of Regular hours : ");

scanf("%f",&regular_hours);

printf("Enter the number of Overtime hours : ");

scanf("%f",&overtime_hours);

grosspay=(regular_hours*rate_of_pay)+(1.5*overtime_hours*rate_of_pay);

netpay=grosspay-(grosspay*0.2);

printf("Employee's Gross pay = %f\n",grosspay);

printf("Tax = %f\n",0.2*grosspay);

printf("Employee's Net pay = %f\n",netpay);

return 0;

}

Note: The variables are declared as float, to support partial hours like 0.5,6.5 etc.

Explanation:

6 0
3 years ago
Melissa needs to put a topic name on her email that she will send will to her teacher . choose the name of the field
Lera25 [3.4K]

It is A. I am pretty sure

8 0
3 years ago
Read 2 more answers
Write a loop that reads strings from standard input where the string is either "land", "air", or "water". The loop terminates wh
____ [38]

Answer:

count_land = count_air = count_water = 0

while True:

   s = input("Enter a string: ")

   if s == "xxxxx":

       break

   else:

       if s == "land":

           count_land += 1

       elif s == "air":

           count_air += 1

       elif s == "water":

           count_water += 1

print("land: " + str(count_land))

print("air: " + str(count_air))

print("water: " + str(count_water))

Explanation:

*The code is in Python

Initialize the variables

Create a while loop that iterates until a specific condition is met. Inside the loop, ask the user to enter the string. If it is "xxxxx", stop the loop. Otherwise, check if it is "land", "air", or "water". If it is one of the given strings, increment its counter by 1

When the loop is done, print the number of strings entered in the required format

4 0
3 years ago
An array of strings , names , has been declared and initialized . write the statements needed to determine whether any of the th
OLEGan [10]
#Python

hasempty = False
for name in names:
   if ( not name ):
      hasempty = True
      break  # speed things up
3 0
3 years ago
Which step creates a connection between a file and a program in python?
Mandarinka [93]
<span>The step of opening a file creates a connection between a file and a program.Opening an output file usually creates the file on the disk and allows the program to write data to it.Opening an input file allows the program to read data from the file.</span>
5 0
3 years ago
Other questions:
  • What are the example of dedicated computers?
    5·1 answer
  • Why is it important to explore an Integrated
    13·1 answer
  • "2. what are the advantages and disadvantages of using the serial console connection compared to the usb console connection to a
    15·1 answer
  • When computing the cost of the basket of goods and services purchased by a typical consumer, which of the following changes from
    11·1 answer
  • Write a small program that takes in two numbers from the user. Using an if statement and an else statement, compare them and tel
    12·1 answer
  • Given a sorted list of integers, output the middle integer. A negative number indicates the end of the input (the negative numbe
    12·1 answer
  • How can your network be infected with malware or ransomware?
    6·1 answer
  • Assume you are using the text's array-based queue and have just instantiated a queue of capacity 10. You enqueue 5 elements and
    13·1 answer
  • Can someone follow my tt its c1ndy.dont.miss
    6·1 answer
  • Why would over-50 executives have a harder time buying into the idea of social media?​
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!