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
Law Incorporation [45]
1 year ago
14

Extend the functionality of cout by implementing a friend function in Number.cpp that overloads the insertion operator. The over

loaded insertion operator returns an output stream containing a string representation of a Number object. The string should be in the format "The value is yourNum", where yourNum is the value of the integer instance field of the Number class.Hint: the declaration of the friend function is provided in Number.h.Ex: if the value of yourNum is 723, then the output is:
Computers and Technology
1 answer:
san4es73 [151]1 year ago
7 0

Answer:

// In the number.cpp file;

#include "Number.h"

#include <iostream>

using namespace std;

Number::Number(int number)

{

   num = number;

}

void Number::SetNum(int number)

{

   num = number;

}

int Number::GetNum()

{

   return num;

}

ostream &operator<<(ostream &out, const Number &n)

{

   out << "The value is " << n.num << endl;

   return out;

}

// in the main.cpp file;

#include "Number.cpp"

#include <iostream>

using namespace std;

int main()

{

   int input;

   cin >> input;

   Number num = Number(input);

   cout << num;  

   return 0;

}

Explanation:

The main function in the main.cpp file prompts the user for the integer value to be displayed. The Number file contains defined functions and methods of the number class to set, get and display the "num" variable.

You might be interested in
Identify the correct language concept or term from the drop-down menu. A Programming Language is a language that physically runs
babymother [125]

Answer and Explanation:

In computer processing of text, a markup language is a way to annotating a document that is different from the book.In the computer, the markup language is a system annotating a text. Such a system uses procedural and descriptive markup. These are called lightweight markup language.

A programming language that physically runs on the website is called display markup.A programming language that is frequently used to develop websites with database is known as JAVA , PHP , HTML ,tags.These are the language that are used with existing markup language.

8 0
1 year ago
Read 2 more answers
When long labels are required, which of these commands can you use to improve readability of a worksheet?
Morgarella [4.7K]
I believe it is wrap text! Hope this helped
6 0
2 years ago
Read 2 more answers
A file concordance tracks the unique words in a file and their frequencies. Write a program that displays a concordance for a fi
victus00 [196]

Answer:

I am writing a Python program.

def concordance(filename):  # function that takes a file name as parameter and returns the concordance for that file

   file = open(filename,"r")  #opens file in read mode

   unique={}  #creates and empty list

   for word in file.read().split():  #loops through every word in the file

       if word in unique:  # if words is already present in the list

           unique[word] += 1  #add 1 to the count of the existing word

       else:    #if word is not present in the list

           unique[word] = 1 #add the word to the list and add 1 to the count of word

           file.close();  # close the file

   for x in sorted(unique):  #sort the list and displays words with frequencies

       print(x, unique[x]);  #prints the unique words and their frequencies in alphabetical order

#prompts user to enter the name of the file

file_name=input('Enter the input file name: ')

concordance(file_name)  #calls concordance method by passing file name to it

Explanation:

The program has a function concordance that takes a text file name as parameter and returns a list of unique words and their frequencies.

The program first uses open() method to open the file in read mode. Here "r" represents the mode. Then creates an empty list named unique. Then the for loop iterates through each word in the file. Here the method read() is used to read the contents of file and split() is used to return these contents as a list of strings. The if condition inside the loop body checks each word if it is already present in the list unique. If the word is present then it adds 1 to the count of that word and if the word is not already present then it adds that unique word to the list and assign 1 as a count to that word. close() method then closes the file. The second for loop for x in sorted(unique):  is used to display the list of unique words with their frequencies. sorted() method is used to sort the list and then the loop iterates through each word in the list, through x, which acts like an index variable, and the loop displays each word along with its frequency.

6 0
1 year ago
Assume that month is an int variable whose value is 1 or 2 or 3 or 5 ... or 11 or 12. Write an expression whose value is "jan" o
Tamiku [17]

Answer:

The code is given below

Explanation:

The correct syntax would be to place appropriate parenthesis.

(month==1?"jan":(month==2?"feb":(month==3?"mar":(month==4?"apr":(month==5?"may":(month==6?"jun":(month==7?"jul":(month==8?"aug":(month==9?"sep":(month==10?"oct":(month==11?"nov":"dec")))))))))));

Similarly, you can also use the following code:

String[] months = { "jan", "feb", "mar", "apr", "may", "jun", "jul", "aug", "sep", "oct", "nov", "dec" };

int month = 1;

String monthDescription = months[month - 1];

7 0
1 year ago
Why are smartphones and tablets capable of handling rich content and interactivity?
NikAS [45]

Answer:

Explanation:

With the advance in technology, smartphones, and tablets are built to meet the ever-increasing needs of users.

Smartphones are mobile phones that also have internet connectivity, they can be used to make calls and perform many tasks just like the conventional desktop. Smartphones and tablets are indeed considered computers because they also process inputs in form of commands and they produce outputs.

Smartphones and tablets are capable of handling rich content and interactivity because:

1. Wireless synchronization with other devices: Just like desktops, laptops, they can interact with other devices, and can receive and also send information doesn't matter the distance.

2. They have Internet connectivity.

3. They have strong hardware, good storage capacity.

4. They have inbuilt software and are capable of accepting other software and programs.

5. They are built with an appealing user interface.

6. Just as computers have processors, smartphones and tablets also have processors to ensure their speed at processing informations.

3 0
2 years ago
Other questions:
  • Which of the following best describes the concept behind Web 2.0
    5·1 answer
  • ____ is a program placed on a computer without the user's knowledge that secretly collects information about the user
    14·1 answer
  • Discuss how the user-designer communications gap can cause a good project to go bad.
    8·1 answer
  • The alternative to encapsulating security protocol (esp) is _________.
    10·1 answer
  • Classify the given items as belonging to the public domain or protected by copyright law.
    6·2 answers
  • A U.S. social security number consists of a string of 9 digits, such as "444422333". Assume that input consists of a sequence of
    6·2 answers
  • Together with some anthropologists, you’re studying a sparsely populated region of a rainforest, where 50 farmers live along a 5
    15·1 answer
  • [Assembly Language]Extended Subtraction Procedure.Create a procedure named Extended_Sub --(Receives: ESI and EDI point to the tw
    12·1 answer
  • Which statement is true about the purpose of a work in process constraint?
    15·1 answer
  • _____________ data is what is translated to digital format so it can be stored in a computer.
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!