answer.
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]
2 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]2 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]2 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
Write a program to read-in a sequence of integers from the keyboard using scanf(). Your program will determine (a) the largest i
Natali [406]
It’s not letting me answer it
3 0
1 year ago
If the object instance is created in a user program, then the object instance can access both the public and private members of
rewona [7]

Answer:

False

Explanation:

The private member of a class is not accessible by using the Dot notation ,however the private member are those which are not accessible inside the class they are accessible outside the class  .The public member are accessible inside the class so they are accessible by using the dot operator .

<u>Following are the example is given below in C++ Language </u>

#include<iostream>   // header file

using namespace std;  

class Rectangle

{    

   private:  

       double r; // private member  

   public:      

       double  area()  

       {     return 3.14*r*r;  

       }        

};  

int main()  

{    

  Rectangle r1;// creating the object  

   r1.r = 3.5;  

 double t= r1.area(); // calling

cout<<" Area is:"<<t;  

   return 0;  

}  

Output:

compile time error is generated

<u>The correct program to access the private member of class is given below </u>

#include<iostream>   // header file

using namespace std;  

class Rectangle

{    

   private:  

       double r; // private member  

   public:      

       double  area()  

       {    

r1=r;

double t2=3.14*r2*r2;

return(t2); // return the value  

       }        

};  

int main()  

{    

  Rectangle r1;// creating the object  

   r1.r = 1.5;  

 double t= r1.area(); // calling

cout<<" Area is:"<<t;  

   return 0;  

}  

Therefore the given statement is False

5 0
2 years ago
Consider the following scenario: "You are an assistant to the accounting manager for a small company that sells sports equipment
Rzqust [24]

Answer:

1. Microsoft Excel helps data analysis through different spreadsheet queries and operations options.

2. Input data to the analysis of sales by product is required for the development of formula and extracting results.

3. The information of data source and frequency of report is required to start the work.

Explanation:

1. Microsoft Excel tool can be used to calculate the results of equipment. Obtained results can be displayed in charts and graphs from the excel.

2. Information like the quantity of sold items, remaining items are required to produce accurate, useful analysis.

Before starting assignment accounting manager will be asked the following questions.

1) Where does the input data come from?

2) Is analysis required on a daily basis or once for all provided data?

3) Is Summary is in the form of tabular data, Graphical data, or Both?

4 0
2 years ago
The groups_per_user function receives a dictionary, which contains group names with the list of users. Users can belong to multi
Akimi4 [234]

The groups_per_user function receives a dictionary, which contains group names with the list of users.

Explanation:

The blanks to return a dictionary with the users as keys and a list of their groups as values is shown below :

def groups_per_user(group_dictionary):

   user_groups = {}

   # Go through group_dictionary

   for group,users in group_dictionary.items():

       # Now go through the users in the group

       for user in users:

       # Now add the group to the the list of

         # groups for this user, creating the entry

         # in the dictionary if necessary

         user_groups[user] = user_groups.get(user,[]) + [group]

   return(user_groups)

print(groups_per_user({"local": ["admin", "userA"],

       "public":  ["admin", "userB"],

       "administrator": ["admin"] }))

3 0
2 years ago
Write a class called Counter that represents a simple tally counter, which might be used to count people as they enter a room. T
Sonja [21]

Answer:

Code is in java

Explanation:

Code is self explanatory, added come comments to explain more about the code.

public class CounterDriver {

   public static void main(String[] args){

       // Creating counter first object

       Counter counter1 = new Counter();

       //performing 2 clicks

       counter1.click();

       counter1.click();

       // displaying counter 1 click count

       System.out.println("Total Number of counter1 clicks :"+counter1.getCount());

       // resetting counter 1 click count

       counter1.reset();

       // again displaying click count which will be 0 after reset

       System.out.println("Total Number of counter1 clicks :"+counter1.getCount());

      // Same operation goes with counter 2  

       // the only difference is that it performs 3 clicks

       Counter counter2 = new Counter();

       counter2.click();

       counter2.click();

       counter2.click();

       System.out.println("Total Number of counter2 clicks :"+counter2.getCount());

       counter2.reset();

       System.out.println("Total Number of counter2 clicks :"+counter2.getCount());

   }

}

class Counter{

   int count;

// defining constructor which will initialize count variable to 0

   public Counter(){

       this.count=0;

   }

// adding click method to increment count whenever it's called

   public void click(){

       this.count++;

   }

// getCount method will return total count

   public int getCount(){

       return this.count;

   }

// reset method will set count to 0

   public void reset(){

       this.count = 0;

   }

}

4 0
2 years ago
Other questions:
  • Which task can a company perform with intranets?
    9·2 answers
  • HELP ASAP U GET BRAINLIEST
    15·2 answers
  • What are threats to computer system
    6·1 answer
  • Select the correct answer. Rachel needs to make a presentation on ethics and etiquettes in college. She has about 30 minutes to
    13·1 answer
  • A technician has been asked to test an inkjet printer purchased 6 months ago that is being pulled from stock and put into use fo
    9·1 answer
  • 14.28. Consider the relation R, which has attributes that hold schedules of courses and sections at a university; R = {Course_no
    7·1 answer
  • This exercise shows why each pivot (in eli1nination by pivoting) must be in a different row. (a) In Example 7, make the third pi
    15·1 answer
  • 7.8.1: Function pass by reference: Transforming coordinates. Define a function CoordTransform() that transforms the function's f
    6·1 answer
  • Look at the following array definition:
    11·1 answer
  • Write an expression that continues to bid until the user enters 'n'.
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!