4 Replies - 236 Views - Last Post: 09 November 2017 - 04:19 AM Rate Topic: -----

#1 JeremyGardel  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 09-November 17

Selection Match Result

Posted 09 November 2017 - 03:22 AM

package match.result;

import java.util.Scanner;


/**
 *
 * @author Jeremy
 */
public class MatchResult {

 
    public static void main(String[] args) 
    {
        String a;
        String b;
        String c;
        String d;
        String e;
        Scanner in = new Scanner(System.in);
        System.out.println("Please, Enter your Match results down here: > Selection from ( A, B, D )");
        a = in.nextLine();
        b = in.nextLine();
        c = in.nextLine();
        d = in.nextLine();
        if(a.equals("A") && b.equals("A") && c.equals("A") || d.equals("A"))
        {
            //e = in.nextLine();
            System.out.println("Team A is the winner.");
        }
        else if(a.equals("A") && b.equals("A"))
        {
            System.out.println("No winners.");
        }
        else if(a.equals("D") && b.equals("D"))
        {
            System.out.println("No winners.");
        }
        else
        {
            System.out.println("No Winner.");
        }


I want at the result here
         if(a.equals("A") && b.equals("A") && c.equals("A") || d.equals("A"))
        {
            //e = in.nextLine();
            System.out.println("Team A is the winner.");
        }


When Entry letter A has the largest count, then A is the winner
Note: this code isn't right, When I type A,A,B,B " It says A is winner but the result must be no winner".

Is This A Good Question/Topic? 0
  • +

Replies To: Selection Match Result

#2 g00se  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 3447
  • View blog
  • Posts: 15,614
  • Joined: 20-September 08

Re: Selection Match Result

Posted 09 November 2017 - 03:42 AM

Quote

When Entry letter A has the largest count, then A is the winner

In that case, why are you not counting the entries?
Was This Post Helpful? 0
  • +
  • -

#3 JeremyGardel  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 09-November 17

Re: Selection Match Result

Posted 09 November 2017 - 03:45 AM

View Postg00se, on 09 November 2017 - 10:42 AM, said:

Quote

When Entry letter A has the largest count, then A is the winner

In that case, why are you not counting the entries?

mm, Gimme an example so I can try doing it
Was This Post Helpful? 0
  • +
  • -

#4 g00se  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 3447
  • View blog
  • Posts: 15,614
  • Joined: 20-September 08

Re: Selection Match Result

Posted 09 November 2017 - 03:53 AM

int[] scores = new int[4];

// (in a loop)
char entry = in.nextLine().charAt(0);
scores[entry-'A']++;

Was This Post Helpful? 0
  • +
  • -

#5 JeremyGardel  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 09-November 17

Re: Selection Match Result

Posted 09 November 2017 - 04:19 AM

View Postg00se, on 09 November 2017 - 10:53 AM, said:

int[] scores = new int[4];

// (in a loop)
char entry = in.nextLine().charAt(0);
scores[entry-'A']++;

Thanks +reped
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1