What's new

Help Help about this program

Maryrose143

Forum Expert
Elite
Joined
Dec 23, 2018
Posts
3,549
Solutions
1
Reaction
17,467
Points
2,749
Mga paps pede pa help

Nahihirapan kasi ako sa program nato

Using function

Ganto kasi

Bali may choices ka like voting given na ang mga tatakbo
Example sina
1:Marcos
2:Juan
3: Pedro

Then may mag ask sayo nang select from the choices [1] for marcos so [2]juan [3]pedro [-1] to exit

Pag nag type ka bali pag di mo pa tinype yung -1 di pa ah sstop kaka ask yung program pero pag nag -1 kana lalabas na ang output

Sample
select from the choices [1] for marcos so [2]juan [3]pedro [-1] to exit :2

select from the choices [1] for marcos so [2]juan [3]pedro [-1] to exit:1

select from the choices [1] for marcos so [2]juan [3]pedro [-1] to exit:1

select from the choices [1] for marcos so [2]juan [3]pedro [-1] to exit:1

select from the choices [1] for marcos so [2]juan [3]pedro [-1] to exit:2

select from the choices [1] for marcos so [2]juan [3]pedro [-1] to exit:-1

Marcos 3
Juan 2
Pedro 0

Baka matulongan nyu po ako

C++ gamit po namin
 
do {
code here
}(condition != -1);

make three int variable to count votes for each candidate

make an else if condition to count their votes and print respectively. thats its
 
[XX='Maryrose143, c: 1026402, m: 1383051'][/XX]
try mo muna to without function, wala kasi ako compiler ikaw na din maglagay ng message
import java.util.Scanner;

class Corruption2021
{
public static int main(String[] sanaol){

Scanner kbd = new Scanner(System.in);
int v1=0, v2=0, v3=0;
int vote = kbd.nextInt();
//Message goes here
while(vote != -1)
{
if(vote == 1)
{
v1++;
}
else if(vote == 2)
{
v2++;
}
else if(vote == 3)
{
v3++;
}
else
//Input error message here
}
//Printout result v1,v2,v3
}
}
 
TS mas maganda na nasimulan mu na ung codes para tulungan ka namin ayusin. Pero kung eexpect mu na kami gagawa ng code nang buo sorry pero ako di ko gagawin un.
 
TS mas maganda na nasimulan mu na ung codes para tulungan ka namin ayusin. Pero kung eexpect mu na kami gagawa ng code nang buo sorry pero ako di ko gagawin un.
Yun nga ssob ehh

Yun nga prob ko di ko alam paano sisimulan kasi nang nag code ako sira utak ko hagahaha
 
1 function na yan lods

Ang prob ko nalang is paano yung pa ulit.x

Sabi ng iba sentinel daw yan

Pero nag sesearch ako no idea talaga
 

Similar threads

Back
Top