Answer to Question #195358 in Java | JSP | JSF for Ggfcvv

Question #195358

It is the final of the world’s most prestigious cricket tournament, the Indian Premier League. In the final, the Chennai Super Kings (CSK) are playing against the Mumbai Indians (MI). There is one over left for the match to end and CSK require R runs to win with W wickets remaining.


1
Expert's answer
2021-05-19T15:51:36-0400
import java.util.Scanner;

public class Tournament {
    int score, R,wicket;
    
    Tournament(int score, int r, int wicket){
        
        this.score=score;
        this.R=r;
        this.wicket=wicket;
        runCount();
        
    }
    
    void runCount(){
        Scanner sc=new Scanner(System.in);
        
        for(int i=0;i<6;i++){
            int run=sc.nextInt();
            if(run<7||run>0){
                System.out.println("Run score in "+i+"isL"+run);
                currentScore(run);
            }else{
                System.out.println("You have entered incorrect value");
            }
        
        }
        
    }
    void currentScore(int run){
        switch(run){
        case 1:
                    System.out.println(score+1);
                    break;
        case 2:
            System.out.println(score+2);
            break;
        case 3:
            System.out.println(score+3);
            break;
        case 4:
            System.out.println(score+4);
            break;
        case 6:
            System.out.println(score+6);
            break;
        case 7:
            System.out.println(score+7);
            break;
            default:
                System.out.println(wicket+1);
        
        }
            
    }

    public int getScore() {
        return score;
    }

    public void setScore(int score) {
        this.score = score;
    }

    public int getR() {
        return R;
    }

    public void setR(int r) {
        R = r;
    }

    public int getWicket() {
        return wicket;
    }

    public void setWicket(int wicket) {
        this.wicket = wicket;
    }

}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS