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.
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;
   }
}
Comments
Leave a comment