473,386 Members | 1,791 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Help: Program For My Class

SOMEONE PLEASE HELP ME.... I HAVE TO REMOVE THE LEADING WHITESPACE IN THIS PROGRAM FOR MY CSE CLASS!!!

IT'S DUE IN A FEW HOURS

PRETTY MUCH IT'S A PROGRAM TO CHANGE NUMBERS FROM ACCOUNTING STYLE TO COMPUTER NUMBERS

FOR EXAMPLE: ($3,432.54) BECOMES -3432.54

IN THE INSTRUCTIONS WE HAVE TO GET RID OF THE LEADING WHITESPACE AND I CAN'T DO IT....


Expand|Select|Wrap|Line Numbers
  1. #include <iostream>
  2. #include <cmath>
  3. #include <fstream>
  4.  
  5. using namespace std;
  6.  
  7. int main()
  8. {
  9.     char InputC;
  10.     ifstream IValues;
  11.     ofstream OValues;
  12.  
  13.     IValues.open("Input Values.txt");
  14.  
  15.     if(IValues.fail())
  16.     {cout << "ERROR: Your accounting file did not open.";
  17.     return 1;}
  18.  
  19.     OValues.open("Output File.txt");
  20.  
  21.     while (!IValues.eof())
  22.     {
  23.     IValues.get(InputC);
  24.     switch(InputC)
  25.     {
  26.     case ' ' : {if (IValues.peek() == ' ' || IValues.peek() == '\t' )
  27.                    break;
  28.                else OValues << " ";} 
  29.     case '\t': {if (IValues.peek() == '\t' || IValues.peek() == ' ' )
  30.                     break;
  31.                else OValues << " ";}
  32.     case '$' : break;
  33.     case ',' : break;
  34.     case '(' : OValues << '-';
  35.     case ')' : break;
  36.     case '.' : OValues << ".";
  37.                 break;
  38.     case '1' : OValues << "1";
  39.                 break;
  40.     case '2' : OValues << "2";
  41.                 break;
  42.     case '3' : OValues << "3";
  43.                 break;
  44.     case '4' : OValues << "4";
  45.                 break;
  46.     case '5' : OValues << "5";
  47.                 break;
  48.     case '6' : OValues << "6";
  49.                 break;
  50.     case '7' : OValues << "7";
  51.                 break;
  52.     case '8' : OValues << "8";
  53.                 break;
  54.     case '9' : OValues << "9";
  55.                 break;
  56.     case '0' : OValues << "0";
  57.                 break;
  58.     case '\n' : OValues << "\n";
  59.     default  : break;
  60.     }}
  61.  
  62.  
  63.  
  64.     return 0;}
Oct 2 '08 #1
3 1254
P.s. I Also Have To Make The Tabs And Spaces One Space
Oct 2 '08 #2
Instead of: IValues.get(InputC)

Just do a normal in... for instance cin<<variable...
instead of variable.get(cin)

The .get function just means that whatever is in front of the word, it will get used as well...
doing a normal cin (as example)... This will ignore whitespace...

As far as I know


Hope this help =)
Oct 2 '08 #3
sicarie
4,677 Expert Mod 4TB
Apolakkiatis-

Please review the Posting Guidelines of this site, specifically the ones that request you: not using all caps, not capitalizing the first letter of every word, using proper English, and using good thread titles.

Now that you 1) are a contributing member (with 30 posts so far) and 2) have been officially asked to review the Guidelines, you will be expected to know and abide by all of them - not just the ones I have referenced.

Thanks,

sicarie
Oct 2 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: Christian Christmann | last post by:
Hi, in the past I always appreciated your help and hope that you also can help me this time. I've spent many many hours but still can't solve the problem by myself and you are my last hope. ...
2
by: Erik | last post by:
Hi Everyone, I'm having real problems compiling some source for eVC4++. The errors I am getting are below: It all seems to be centred around winsock. If I move the afsock.h reference to before...
1
by: dasilva109 | last post by:
Hi guys I am new to C++ and need urgent help with this part of my code for a uni coursework I have to submit by Thursday //ClientData.h #ifndef CLIENTDATA_H #define CLIENTDATA_H #include...
1
by: lilbit02 | last post by:
Hi, I have a form that utilizes validation as most do via javascript. This form worked totaly fine until I needed to add a dynamic div now the validation doesn't work. It does work for the first...
2
by: bmbvm5 | last post by:
Hello; I am beginner in java and I should submit one java program in early day. I try to write this program more then ten time but every time I find one broblem. Please help me because if you...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.