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. -
-
#include <iostream>
-
using namespace std;
-
class Interface
-
{
-
private:
-
int issue1;
-
int issue2;
-
int issue3;
-
public:
-
Interface(int=0,int=0,int=0);
-
~Interface(){};
-
void SetInterface(int i1,int i2, int i3);
-
void Setissue1();
-
void Setissue2();
-
void Setissue3();
-
int Getissue1();
-
int Getissue2();
-
int Getissue3();
-
};
-
Interface::Interface(int issue1,int issue2,int issue3)
-
{
-
SetInterface(issue1,issue2,issue3);
-
}
-
void Interface::SetInterface(int i1, int i2, int i3)
-
{
-
-
}
-
void Interface::Setissue1()
-
{
-
int ans=0;
-
do
-
{
-
cout<<endl<<"Question 1: "<<endl;
-
cout<<"1) Do you use Microsoft Windows?"<<endl;
-
cin>>ans;
-
if (ans<0||ans>1)
-
cout<<"Please select 0 for NO or 1 for YES."<<endl;
-
}
-
while (ans<0||ans>1);
-
-
}
-
void Interface::Setissue2()
-
{
-
int ans=0;
-
do
-
{
-
cout<<endl<<"Question 2: "<<endl;
-
cout<<"2) Are you in favor of open source software?"<<endl;
-
cin>>ans;
-
if (ans<0||ans>1)
-
cout<<"Please select 0 for NO or 1 for YES."<<endl;
-
}
-
while (ans<0||ans>1);
-
}
-
void Interface::Setissue3()
-
{
-
int ans=0;
-
do
-
{
-
cout<<endl<<"Question 3: "<<endl;
-
cout<<"3) Do you enjoy programming?"<<endl;
-
cin>>ans;
-
if (ans<0||ans>1)
-
cout<<"Please select 0 for NO or 1 for YES."<<endl;
-
}
-
while (ans<0||ans>1);
-
}
-
int Interface::Getissue1()
-
{
-
return (issue1);
-
}
-
int Interface::Getissue2()
-
{
-
return (issue2);
-
}
-
int Interface::Getissue3()
-
{
-
return (issue3);
-
}
-
class Tally
-
{
-
private:
-
int issue1_y, issue1_n, issue2_y, issue2_n, issue3_y, issue3_n;
-
public:
-
Tally();
-
~Tally(){};
-
int add1(int ans);
-
int add2(int ans);
-
int add3(int ans);
-
};
-
Tally::Tally()
-
{
-
cout<<"Constructor"<<endl;
-
issue1_y=0;
-
issue1_n=0;
-
issue2_y=0;
-
issue2_n=0;
-
issue3_y=0;
-
issue3_n=0;
-
}
-
int Tally::add1(int ans)
-
{
-
if (ans==0)
-
{
-
++issue1_n;
-
}
-
else if (ans==1)
-
{
-
++issue1_y;
-
}
-
cout<<"No: "<<issue1_n<<endl<<"Yes: "<<issue1_y<<endl;
-
return(0);
-
}
-
int Tally::add2(int ans)
-
{
-
if (ans==0)
-
++issue2_n;
-
else if (ans==1)
-
++issue2_y;
-
return (0);
-
-
}
-
int Tally::add3(int ans)
-
{
-
if (ans==0)
-
++issue3_n;
-
else if (ans==1)
-
++issue3_y;
-
return (0);
-
}
-
void main()
-
{
-
int num=0, ans=0, i=1;
-
Tally counter;
-
Interface Interface;
-
cout<<"Welcome to the tally program."<<endl;
-
cout<<"For all issues enter 0 for NO and 1 for YES."<<endl;
-
cout<<"How many voters do you have?"<<endl;
-
cin>>num;
-
do
-
{
-
cout<<endl<<"Voter: "<<i<<endl;
-
Interface.Setissue1();
-
Interface.Getissue1();
-
counter.add1(Interface.Getissue1());
-
Interface.Setissue2();
-
Interface.Getissue2();
-
counter.add2(Interface.Getissue2());
-
Interface.Setissue3();
-
Interface.Getissue3();
-
counter.add3(Interface.Getissue3());
-
--num;
-
++i;
-
}
-
while (num>0);
-
}
-
-
Thanks,
J
1 4292
Problem has been resolved.
J
Sign in to post your reply or Sign up for a free account.
Similar topics |
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...
|
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 ...
|
by: anjana |
last post by:
hi,
just tell me how to connect asp.net with tally
|
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
|
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
| |
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.....
|
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
|
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??
|
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 .
|
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...
|
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,...
| |
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...
|
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,...
|
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...
|
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...
|
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();...
|
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
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |