Profile Report

Candidate Details
user-img
Overall competency
Pass
Pass Percentage : 50
100%
Assessment Details
Attempt Details

Candidate Score
Answer Summary
Question 1 : Run Rate

C#

Scenario:

India vs. Srilanka world cup final match. India won the toss and chooses to bowl. Srilanka scored 274-6 in 50 overs. Write a program to calculate the run rate for India in a given number of overs to score 275. The number of overs will be the input. The run rate to score 275 in a given number of overs will be the output.

RULES:
1.Create a class WorldCup with a method RunRate which accepts an integer.
2.The return type of RunRate is double.
3.Create a class Finals which is used the call the methods in WorldCup.
4.Overs should be in the range 20 and 50
5.If over is not in the given range,the statement "Over should be in the range 20 to 50" should be displayed.
6.If over is not in the type of integer,the statement "Over should be integer" should be displayed

Sample Input:
40

Sample output:
6.75

Submitted Code

C#

Main.cs
 using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CricketAverage
{

 class WorldCup
    {
        public float target = 275;
        public int no_of_overs;
        public float runrate;
        public void RunRate()
        {
            try
            {
                var Input = Console.ReadLine();
                if (Input == "")
                {
                    Console.WriteLine("Overs should not be empty");
                }
                else
                {
                    no_of_overs = Convert.ToInt32(Input);
                    if (no_of_overs > 50)
                    {
                        Console.WriteLine("Over should be in the range 20 to 50");
                    }
                    else if (no_of_overs < 0)
                    {
                        Console.WriteLine("Over should be in integer type");
                    }
                    else if (no_of_overs < 20)
                    {
                        Console.WriteLine("Over should be in the range 20 to 50");
                    }
                    else
                    {
                        runrate = target / no_of_overs;
                        Console.WriteLine(runrate);
                    }
                }
            }
            catch (Exception e)
            {
                e.ToString();
                Console.WriteLine("Overs Should be Integer");
            }
        }
    }
    class Finals
    {
        static void Main(string[] args)
        {

         WorldCup n = new WorldCup();
            n.RunRate();
            Console.ReadLine();
        }
    }
} 
Test case execution
Test Case Actual Input Expected Output Obtained Output Status
General Testcase
40
6.875
6.875
True
Boundary Testcase
12
Over should be in the range 20 to 50
Over should be in the range 20 to 50
True
Negative Testcase
-40
Over should be in integer type
Over should be in integer type
True
Question 2 : Toggle String

C++

Scenario:

You have been given a String SS consisting of uppercase and lowercase English alphabets. You need to change the case of each alphabet in this String. That is, all the uppercase letters should be converted to lowercase and all the lowercase letters should be converted to uppercase. You need to then print the resultant String to output.

Input Format:

The first and only line of input contains the String SS

Output Format:

Print the resultant String on a single line.

Constraints:

1≤|S|≤1001≤|S|≤100 where |S||S| denotes the length of string SS.

Submitted Code

C++

Main.cpp
 #include 
using namespace std; 
int main()
{     
      string s;
      cin >> s ;    
      int len=s.length();
      for (int i=0;i='A' && s[i] <= 'Z'){              
            s[i]=s[i]+32;                 
          }
          else if (s[i] >='a' && s[i]<= 'z'){            
            s[i]=s[i]-32;                  
          }                
      } 
      cout << s;      
    return 0;
} 
Test case execution
Test Case Actual Input Expected Output Obtained Output Status
General Testcase
40
6.875
6.875
True
Boundary Testcase
12
Over should be in the range 20 to 50
Over should be in the range 20 to 50
True
Test case execution
Test Case Actual Input Expected Output Obtained Output Status
General Testcase
40
6.875
6.875
True
Boundary Testcase
12
Over should be in the range 20 to 50
Over should be in the range 20 to 50
True

Report generated time : 14-05-2019 06:46:05

Powered by banyan-logo