im having trouble with my output i want to justify it the name and the result but i dont dont how when i enter a number it is not centered......pls help me this is my codes
#include "stdafx.h"
#include <iostream>
#include <conio.h>
#include <string>
#include <windows.h>
using namespace std;
void main()
{
int cartoon;
int voters;
int spongebob=0;
int patrick=0;
int y;//loop
char x='*';
int t;//total
cout<<"Choose your favorite Cartoon Character"<<endl;
cout<<"PRESS 1 for spongebob"<<endl;
cout<<"PRESS 2 for patrick"<<endl;
cout<<"Enter the number of voters:";
cin>>voters;
for(y=1;y<=voters;y++)
{
cout<<"Survey for your favorite Cartoon Character:";
cin>>cartoon;
if(cartoon==1)
{
spongebob=spongebob+1;
}
else if (cartoon==2)
patrick=patrick+1;
}
cout<<"Total votes:"<<endl;
x=spongebob/1;
cout<<"votes from spongebob:"<<spongebob<<endl;
for(t=1;t<=x;t++)
{
cout<<'*';
cout<<endl;
}
x=patrick/1;
cout<<"votes from patrick:"<<patrick<<endl;
for(t=1;t<=x;t++)
{
cout<<'*';
cout<<endl;
}
getch();
}
and this is my recent output
i want to justify it the result and the name please im not that good in c++ pls help.. this is my sample:
choose your favorite cartoon character
PRESS 1 for spongebob
PRESS 2 for patrick
Enter the number of voter:5
Survey for your favorite cartoon character:1
Survey for your favorite cartoon character:2
Survey for your favorite cartoon character:1
Survey for your favorite cartoon character:2
Survey for your favorite cartoon character:1
total votes:
Votes from spongebob:3
*
*
*
votes from ptrick:2
*
*