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
Anna71 [15]
4 years ago
11

Suppose your name was George Gershwin. Write a complete program that would print your last name, followed by a comma, followed b

y your first name. Do not print anything else (that includes blanks).
Computers and Technology
2 answers:
NNADVOKAT [17]4 years ago
6 0

Answer:

I will write the code in C++ and JAVA      

Explanation:

<h2>JAVA CODE</h2>

public class Main

{ public static void main(String[] args) {

       // displays Gershwin,George

     System.out.println("Gershwin,George"); }  }

<h2>C++ Code:</h2>

#include <iostream>

using namespace std;  

int main()

{  cout<<"Gershwin,George"; }    

// displays last name Gershwin followed by , followed by first name George

//displays Gershwin,George as output.

larisa86 [58]4 years ago
5 0
<h2>ANSWER</h2>

=> Code

public class Name{

    public static void main(String [ ] args){

          String firstname = "George";

          String lastname = "Gershwin";

          System.out.println(lastname + "," + firstname);

    }

}

=> Output

Gershwin,George

<h2>EXPLANATION</h2>

The code has been written in Java. The following is the line by line explanation of the code.

// Declare the class header

public class Name{

    // Write the main method for the code.

    public static void main(String [ ] args){

         

          // Declare a string variable called firstname and initialize it to hold the

          // first name which is <em>George</em>.

          String firstname = "George";

          // Declare a string variable called lastname and initialize it to hold the

          // last name which is <em>Gershwin</em>.

          String lastname = "Gershwin";

          // Print out the lastname followed by a comma and then the firstname

          System.out.println(lastname + "," + firstname);

    }      // End of main method

}           // End of class declaration

<h2></h2><h2>NOTE</h2>

The explanation of the code has been written above as comments. Please go through the comments of the code for more understanding.

Nevertheless, a few things are worth noting.

(i) Since it is a complete program, a main class (<em>Name</em>, in this case) has to be defined. The main class has a main method where execution actually begins in Java.

(ii) The first name (George) and last name (Gershwin) are both string values therefore they are to be stored in a String variable. In this case, we have used variable <em>firstname </em>to hold the first name and <em>lastname </em> to hold the last name. Remember that variable names must not contain spaces. So variable names <em>lastname </em>and <em>firstname</em>, though compound words, have been written without a space.

(iii)The System.out.println() method is used for printing to the console in Java and has been used to print out the concatenated combination of last name and first name separated by a comma.

(iv) In Java, strings are concatenated using the + operator. To concatenate two strings lastname and firstname, write the following:

lastname + firstname.

But since they are separated by a comma, it is written as:

lastname + "," + firstname

You might be interested in
SOMETHING WRONG WHAT WRONG!!!!!!!
Evgen [1.6K]
You have the mode wrong, there are 2 of them 5, and 6!

4 0
3 years ago
Read 2 more answers
Why do i have to wait and watch videos
Mila [183]

The reason being is because of your search history. Google will remember everything you like to watch, look, play or buy things on the computer or any device with internet. Since you are interested in the things you like to do, you're computer will remember this and will display Ads made by companies, or people, which possibly may be a scam, or may give a virus. I would advise to avoid these things as much as you can.

7 0
3 years ago
You must establish credit in order to buy a house true or false
Stolb23 [73]
I believe this is true.
8 0
3 years ago
Read 2 more answers
How many binary digits are in 10^100.
Basile [38]

Answer:

333 binary digits.

Explanation:

8 0
2 years ago
A is a program for editing,rearranging and storing text
UNO [17]

Answer:

text editor

Explanation:

hope it helps

4 0
3 years ago
Read 2 more answers
Other questions:
  • Define a Course base class with attributes number and title. Define a print_info() method that displays the course number and ti
    14·1 answer
  • The _______ displays the name of the open file and the program.
    13·1 answer
  • After a worksheet has been displayed in page layout view, page breaks are indicated by ________ in normal view.
    14·1 answer
  • Caitlyn's Crafty Creations computes a retail price for each product as the cost of materials plus $14 multiplied by the number o
    10·1 answer
  • The ____ of a variable is the location in memory where it’s value is stored. A. Value B. Address C. Data type D. Number
    8·1 answer
  • A _____ is a control that tells the computer what task to perform.
    6·1 answer
  • Does trend in computing important for organization management?​
    8·1 answer
  • Can we update App Store in any apple device. (because my device is kinda old and if want to download the recent apps it aint sho
    10·1 answer
  • A ______ uses a web address to locate a website or a web page.
    9·1 answer
  • Why do we need to know the different Networking Devices?​
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!