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
Jobisdone [24]
3 years ago
13

Write a program (C++) that reads a number between 1,000 and999,999 from the user where the user enters a comma in the input.Then

print the number without a comma. EXAMPLE:Here is a sample dialog, the user input is in italics.
Computers and Technology
1 answer:
mr Goodwill [35]3 years ago
7 0

<u>C++ program to print the digit without a comma </u>

#include<iostream>

#include<string>

using namespace std;

void commaremoval(string num)  /*Defining function commaremoval with parameter num of string type*/

{  

string  s=num;

for(int i=0; i< s.length();i++)

   {

    if(s[i]!=',') /*Checking whether the string doesn't contain ' ,' */

       cout<<s[i];  //Printing Output without comma

   }  

}

//driver function

int main()

{

string num;

cout<<"Enter a digit between 1,000 and 999,999:"<<endl; /*taking input from user*/

cin>>num;

commaremoval(num); //calling function

return 0;

}

<u>Output</u>

Enter a digit between 1,000 and 999,999:  22,343

22343

You might be interested in
C++
daser333 [38]

#include<iostream>

#include <fstream>

#include <vector>

#include <string>

#include "StatePair.h"

using namespace std;

int main() {

ifstream inFS;

int zip;

int population;

string abbrev;

string state;

unsigned int i;

vector<StatePair <int, string>> zipCodeState;

vector<StatePair<string, string>> abbrevState;

vector<StatePair<string, int>> statePopulation;

inFS.open("zip_code_state.txt");

if (!inFS.is_open()) {

    cout << "Could not open file zip_code_state.txt." << endl;

    return 1;

}

while (!inFS.eof()) {

    StatePair <int, string> temp;

    inFS >> zip;

    if (!inFS.fail()) {

        temp.SetKey(zip);

    }

    inFS >> abbrev;

    if (!inFS.fail()) {

        temp.SetValue(abbrev);

    }

    zipCodeState.push_back(temp);

}

inFS.close();

inFS.open("abbreviation_state.txt");

if (!inFS.is_open()) {

    cout << "Could not open file abbreviation_state.txt." << endl;

    return 1;

}

while (!inFS.eof()) {

    StatePair <string, string> temp;

    inFS >> abbrev;

    if (!inFS.fail()) {

        temp.SetKey(abbrev);

    }

    getline(inFS, state);

    getline(inFS, state);

    state = state.substr(0, state.size()-1);

    if (!inFS.fail()) {

        temp.SetValue(state);

    }

    abbrevState.push_back(temp);

}

inFS.close();

inFS.open("state_population.txt");

if (!inFS.is_open()) {

    cout << "Could not open file state_population.txt." << endl;

    return 1;

}

while (!inFS.eof()) {

    StatePair <string, int> temp;

    getline(inFS, state);

    state = state.substr(0, state.size()-1);

    if (!inFS.fail()) {

        temp.SetKey(state);

    }

    inFS >> population;

    if (!inFS.fail()) {

        temp.SetValue(population);

    }

    getline(inFS, state);

    statePopulation.push_back(temp);

}

inFS.close();

cin >> zip;

for (i = 0; i < zipCodeState.size(); ++i) {

 }

for (i = 0; i < abbrevState.size(); ++i) {

 }

for (i = 0; i < statePopulation.size(); ++i) {

}

}

Statepair.h

#ifndef STATEPAIR

#define STATEPAIR

#include <iostream>

using namespace std;

template<typename T1, typename T2>

class StatePair {

private:

T1 key;

T2 value;

public:

StatePair()

{}

void SetKey(T1 key)

{

this->key = key;

}

void SetValue(T2 value)

{

this->value = value;

}

T1 GetKey() { return key;}

T2 GetValue() { return value;}

void PrintInfo()

{

cout<<key<<" : "<<value<<endl;

}

};

3 0
2 years ago
A school principal trying to find out if parents will help buy new playground equipment shows digital leadership by.
ELEN [110]

Answer:

D. is the correct answer!

8 0
4 years ago
Read 2 more answers
Will give Brainiest and stuff to right answer[s].
Aneli [31]
#22 is 1s and 0s, hope that helps a little bit
6 0
3 years ago
Read 2 more answers
B. List any four major drawbacks of the first generation computer​
d1i1m1o1n [39]

Answer:

Terribly low storage space, limited to mathematics/computing, required entire rooms to use, and low information yield for hours of processing.

Explanation:

3 0
3 years ago
PLEASE HELP WITH MY COMPUTER
qaws [65]

Answer:

try powering it off the turn it back on

Explanation:

5 0
3 years ago
Read 2 more answers
Other questions:
  • What does "FDDI" stand for in Technology?
    5·2 answers
  • You can use RWA to demonstrate how to do something special on the web, such as displaying articles found on websites that suppor
    15·1 answer
  • Describe one type of technology that is useful in producing images from space.
    9·1 answer
  • What would be one duty of a network administrator
    12·1 answer
  • Which of the following is NOT true about RMI? RMI uses the socket connection, including opening and closing the socket. RMI allo
    8·1 answer
  • Although designed to support remote dial-in access to a corporate network, what service below is commonly used with 802.1x port
    12·1 answer
  • The variable most_recent_novel is associated with a dictionary that maps the names of novelists to their most recently published
    12·1 answer
  • Why is it important to use random assignment when determining which research participants will comprise the different treatment
    12·1 answer
  • Write a program to find area of rectangle​
    12·1 answer
  • The sun emits invisible _____&gt; A) electromagnetic waves B) Waves C) Radiation D) Wavelength E) Ultraviolet Light
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!