473,624 Members | 2,408 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Tally machine program

87 New Member
Well on to my next program. The program tally's votes on 3 issues. I have a class for the interface (asks questions) and a class for adding the tallies. In main there is a counter of Tally data type. I'm unclear how to actually tally the votes. I have tried sending the counter.add function the GetIssue1 value, however this does not work.

Expand|Select|Wrap|Line Numbers
  1.  
  2. #include <iostream>
  3. using namespace std;
  4. class Interface
  5. {
  6. private: 
  7.     int issue1;
  8.     int    issue2;
  9.     int issue3;
  10. public:
  11.     Interface(int=0,int=0,int=0);
  12.     ~Interface(){};
  13.     void SetInterface(int i1,int i2, int i3);
  14.     void Setissue1();
  15.     void Setissue2();
  16.     void Setissue3();
  17.     int Getissue1();
  18.     int Getissue2();
  19.     int Getissue3();
  20. };
  21. Interface::Interface(int issue1,int issue2,int issue3)
  22. {
  23.     SetInterface(issue1,issue2,issue3);
  24. }
  25. void Interface::SetInterface(int i1, int i2, int i3)
  26. {
  27.  
  28. }
  29. void Interface::Setissue1()
  30. {
  31.     int ans=0;
  32.         do
  33.         {
  34.         cout<<endl<<"Question 1: "<<endl;
  35.         cout<<"1) Do you use Microsoft Windows?"<<endl;
  36.         cin>>ans;
  37.             if (ans<0||ans>1)
  38.                 cout<<"Please select 0 for NO or 1 for YES."<<endl;
  39.         }
  40.         while (ans<0||ans>1);
  41.  
  42. }
  43. void Interface::Setissue2()
  44. {
  45.     int ans=0;
  46.     do
  47.         {
  48.         cout<<endl<<"Question 2: "<<endl;
  49.         cout<<"2) Are you in favor of open source software?"<<endl;
  50.         cin>>ans;
  51.             if (ans<0||ans>1)
  52.                 cout<<"Please select 0 for NO or 1 for YES."<<endl;
  53.         }
  54.         while (ans<0||ans>1);
  55. }
  56. void Interface::Setissue3()
  57. {
  58.     int ans=0;
  59.     do
  60.         {
  61.         cout<<endl<<"Question 3: "<<endl;
  62.         cout<<"3) Do you enjoy programming?"<<endl;
  63.         cin>>ans;
  64.             if (ans<0||ans>1)
  65.                 cout<<"Please select 0 for NO or 1 for YES."<<endl;
  66.         }
  67.         while (ans<0||ans>1);
  68. }
  69. int Interface::Getissue1()
  70. {
  71.     return (issue1);
  72. }
  73. int Interface::Getissue2()
  74. {
  75.     return (issue2);
  76. }
  77. int Interface::Getissue3()
  78. {
  79.     return (issue3);
  80. }
  81. class Tally
  82. {
  83. private:
  84.     int issue1_y, issue1_n, issue2_y, issue2_n, issue3_y, issue3_n;
  85. public:
  86.     Tally();
  87.     ~Tally(){};
  88.     int add1(int ans);
  89.     int add2(int ans);
  90.     int add3(int ans);
  91. };
  92. Tally::Tally()
  93. {
  94.     cout<<"Constructor"<<endl;
  95.     issue1_y=0;
  96.     issue1_n=0;
  97.     issue2_y=0;
  98.     issue2_n=0;
  99.     issue3_y=0;
  100.     issue3_n=0;
  101. }
  102. int Tally::add1(int ans)
  103. {
  104.     if (ans==0)
  105.     {
  106.         ++issue1_n;
  107.     }
  108.     else if (ans==1)
  109.     {
  110.         ++issue1_y;
  111.     }
  112.     cout<<"No: "<<issue1_n<<endl<<"Yes: "<<issue1_y<<endl;
  113.     return(0);
  114. }
  115. int Tally::add2(int ans)
  116. {
  117.     if (ans==0)
  118.         ++issue2_n;
  119.     else if  (ans==1)
  120.         ++issue2_y;
  121.     return (0);
  122.  
  123. }
  124. int Tally::add3(int ans)
  125. {
  126.     if (ans==0)
  127.         ++issue3_n;
  128.     else if (ans==1)
  129.         ++issue3_y;
  130.     return (0);
  131. }
  132. void main()
  133. {
  134.     int num=0, ans=0, i=1;
  135.     Tally counter;
  136.     Interface Interface;
  137.     cout<<"Welcome to the tally program."<<endl;
  138.     cout<<"For all issues enter 0 for NO and 1 for YES."<<endl;
  139.     cout<<"How many voters do you have?"<<endl;
  140.     cin>>num;
  141.     do
  142.     {
  143.         cout<<endl<<"Voter: "<<i<<endl;
  144.         Interface.Setissue1();
  145.         Interface.Getissue1();
  146.         counter.add1(Interface.Getissue1());
  147.         Interface.Setissue2();
  148.         Interface.Getissue2();
  149.         counter.add2(Interface.Getissue2());
  150.         Interface.Setissue3();
  151.         Interface.Getissue3();
  152.         counter.add3(Interface.Getissue3());
  153.         --num;
  154.         ++i;
  155.     }
  156.     while (num>0);
  157. }
  158.  
  159.  

Thanks,
J
Jul 18 '07 #1
1 4292
Hypnotik
87 New Member
Problem has been resolved.

J
Jul 18 '07 #2

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

Similar topics

6
2281
by: Ronald | last post by:
Hi there, I would like to challenge you all to make the fastest tally-function possible. The function should count the number of times a specified string is present within another string. As I'm a Visual Basic programmer I think i've reached the limits of performance from VB. In VB the fastest (until now) function looks like this: ---------------------------------------------------------------------------- Function Tally(ByVal sString...
1
3266
by: Shannan Casteel via AccessMonster.com | last post by:
If I had 2 tables, one that displayed ClaimNo, PartNo, and Quantity, and another that just has PartNo and Quantity, how could I get Access to search for the PartNo in table 2 that was entered in table 1, then if it found it add the associated quantity to table 2 from table 1, and if it is not found to add it, with its associated quantity to table 2. This should be simple.....its just a running total/tally.... Table 1 ClaimNo ...
2
2165
by: anjana | last post by:
hi, just tell me how to connect asp.net with tally
0
1553
by: vidhyapriya | last post by:
hi all i want to connect tally software in my .net application...i want to transfer data between tally software and by windows apllication(or)web application...i heard is it possible to do using RTSLink DLL....is there any other way to do this.... help me... thanks
1
1631
sheenattt
by: sheenattt | last post by:
Hello all, How can I use Tally in .Net?I want to map Tally to web based application,means is it possible to click a link and we can import or export tally to web.I want to put authentication also for such.Please do help me soon. Sheena
3
3224
by: pub | last post by:
Hello..im a junior programmer( a beginner) in .NET C#..... so i really dono hw to use tally 9...so plzzzzz witot any set bak help me in learning n handling tally 9......plzzzz provide me de links where i cn learn tally frm scratch.....
9
21338
by: sathikbasha | last post by:
hi Please help me !!!!!!! how to connect the Tally from VB. Is there any ODBC connection in Tally Software. I need to import the data from SQL Server to Tally. regards
4
9922
by: shailendraedreamz | last post by:
Hi, As in .Net we can connect to Oracle database using OracleClient Name Space. In the same manner can we connect to Tally database directly. Is .Net have provided such facility??
1
2563
by: Vikrant kale | last post by:
I have created a accounting software in asp.net with sql server 2005 database . my customer is already using tally 9.0 and he want to integrate tally to my database to reduce double entry. would anyone help me out .
0
8240
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8175
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8625
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8336
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8482
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6111
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5565
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
2610
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1791
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.