Question

What is this graph translated into Java CodeShortest path algorithm Suppose that the league matches are played between the X and Y teams. The team X is containing D, E,

0 0
Add a comment Improve this question Transcribed image text
Answer #1

//Your code

import java.util.*;
import java.lang.*;
import java.io.*;
public class Game{
   public static void main(String []args){
       int mat[][] = new int[6][6];
       System.out.println("Enter all edges (u,v)\nTo stop enter exit");
       Scanner sc = new Scanner(System.in);
       String a;
       int i,j,u,v;
       for( i = 0 ; i < 6 ; i++ ){
           for( j = 0 ; j < 6 ; j++ )
               mat[i][j]=0;  
       }
       while(true){
           a=sc.nextLine();
           if(a.compareTo("exit") == 0)break;
           u = a.charAt(0)-'A';
           v = a.charAt(2)-'A';
           mat[u][v]=1;  
           //System.out.println(u+ " " + v);
          
       }
       int win[] = new int[6];
       for( i = 0 ; i < 6 ; i++ ){
           win[i]=0;
       }
       for(i = 0 ; i <6 ; i++ ){
           for( j = 0 ; j < 6 ; j++ ){
               if(mat[i][j] ==1 )
                   win[i]++;
               if(mat[j][i] == 1)
                   win[i]--;
           }
       }
       int Y=0,X=0;
       for( i = 0 ; i < 6 ; i++ ){
           if(i<3){
               if(win[i] >0)
               Y+=1;
           }
           else{
               if(win[i] >0)
               X += 1;
           }  
       }
       System.out.println("Y Team");
       System.out.println("Win = "+Y+"\nLose = "+(3-Y));
       System.out.println("X Team");
       System.out.println("Win = "+X+"\nLose = "+(3-X));
       if(Y > X){
           System.out.println("Team Y wins");
           System.out.println("Team X Lose");
           }else{
           System.out.println("Team X wins");
           System.out.println("Team Y Lose");
       }

   }
}

//Screenshot of editor

Activities Text Editor Thu Mar 21, 12:02 Open ▼ 四 Game.java Save E import java.util.*; import java.Lang. import java.io.*; pu

//Output terminal Screenshot

Activities -Terminal ▼ Thu Mar 21, 12:02 83 96 ambuj@ambuj: /HomeworkLib File Edit View Search Terminal Help anbuj@ambuj:-/HomeworkLib$ j

//This is java code for this Game.You need to enter edges in format u v where u is source and v is destination.

You will get final result.

If you have any doubt.Please feel free to ask.Thanks.

Add a comment
Know the answer?
Add Answer to:
What is this graph translated into Java Code Shortest path algorithm Suppose that the league matches...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Suppose major league baseball consists if two types of teams: profit maximizing teams (e.g., Rays) and...

    Suppose major league baseball consists if two types of teams: profit maximizing teams (e.g., Rays) and win maximizing teams (e.g., Red Sox). Before the season, each team decides the number of expected wins they are going to get that season by constructing a roster of players. Fans enjoy wins, but the additional revenue of each win is decreasing and given by the following average revenue (inverse demand) curve ARW) 320-2W It is costly to increase the expected number of wins...

  • Suppose major league baseball consists if two types of teams: profit maximizing teams (e.g., Rays) and...

    Suppose major league baseball consists if two types of teams: profit maximizing teams (e.g., Rays) and win maximizing teams (e.g., Red Sox). Before the season, each team decides the number of expected wins they are going to get that season by constructing a roster of players. Fans enjoy wins, but the additional revenue of each win is decreasing and given by the following average revenue inverse demand) curve: P(W) = AR(W) = 320 - 2W It is costly to increase...

  • There is a football game between two rival teams -- Team 0 and Team 1. Suppose...

    There is a football game between two rival teams -- Team 0 and Team 1. Suppose Team 0 wins 65% of the time and Team 1 wins the remaining matches. Among the games won by Team 0, only 30% of them come from playing on Team 1’s football team. On the other hand, 75% of the victories for Team 1 are obtained while playing at home. If Team 1 is to host the next match between the two teams, which...

  • 5. The World Series determines the national championship team for Major League Baseball. In the World...

    5. The World Series determines the national championship team for Major League Baseball. In the World Series, two teams (A and B) play a series of games until one wins 4 games. Assume that the games are played independently and the probability that Team A wins is 0.40 and this does not change from game to game. Let the random variable X represent the total number of games required in a randomly selected World Series. The CDF for X is:...

  • The National Football League (NFL) records a variety of performance data for Individuals and team...

    The National Football League (NFL) records a variety of performance data for Individuals and teams. To investigate the importance of passing on the percentage of games won by a team, the following data show the average number of passing yards per attempt (Yds/Att) and the percentage of games won (Win96) for a random sample of 10 NFL teams. Team Team 1 Team 2 Team 3 Team 4 Team 5 Team б Team 7 Team 8 Team 9 Team 10 Yds/Att...

  • Next weekend Team A plays a 5 game series against their nemesis Team D. Team A...

    Next weekend Team A plays a 5 game series against their nemesis Team D. Team A has a 65% chance of winning each game, independent of others. Let X denote the number of games that Team A wins in a 5 game series. 6 Use the PDF of X to find the expectation 4 = EX and variance Var(X). 7 Then use a formula from Ch 4.6 to quickly find these. 8 On average, how many games need to be...

  • The National Football League (NFL) records a variety of performance data for individuals and teams. ail...

    The National Football League (NFL) records a variety of performance data for individuals and teams. ail Sprint Wi-Fi 9:52 PM 18% Access WebAssign My Notes Previous Answers DATAfile: NFLPassing A statistical program is recommended The National Football League (NFL) records a variety of performance data for individuals and teams. To investigate the importance of passing on the percentage of games won by a team, the following data show the conference (Conf), average number of passing yards per attempt (Yds/Att), the...

  • (e pointa) Two national foot ball teams, Swemark and Denden, are playing each other in the...

    (e pointa) Two national foot ball teams, Swemark and Denden, are playing each other in the group stage of the European championships. The points they have secured in the games they have already played mean that if one team wins they will go forward to the knock out stage of the competition and the other team will not. However if they make a draw they will both go through to the next stage at the expense of another national side....

  • Please show instructions on how you got the answer. Thank you. Question 1: Question 2: Given...

    Please show instructions on how you got the answer. Thank you. Question 1: Question 2: Given are five observations for two variables, x and y. 1 2 3 4 (a) Develop a scatter diagram for these data. (b) What does the scatter diagram developed in part (a) indicate about the relationship between the two variables? There appears to be a negative linear relationship between x and y. There appears to be a positive linear relationship between x and y. There...

  • Using Java You are helping a corporation create a new system for keeping track of casinos...

    Using Java You are helping a corporation create a new system for keeping track of casinos and customers. The system will be able to record and modify customer and casino information. It will also be able to simulate games in the casino. Customer-specific requirements You can create new customers All new customers have a new customerID assigned to them, starting with 1 for the first, 2 for the second, 3 for the third, ect. New customers have names and monetary...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT