Write a program to create a menu-driven calculator that performs basic arithmetic operations (+, -, *, /, and %).Input
The input will be a single line containing two integers and operator(+, -, *, /, and %) similar to 3 + 5.Output
If the given operator is "+", print the sum of two numbers.
If the given operator is "-", print the result of the subtraction of the two numbers.
If the given operator is "*", print the multiplication of the two numbers.
For example, if the given operator is "+" and the two numbers are 3 and 5. As it is an addition operator, your code should print the sum of the given two numbers (3 + 5), which is 8.
Similarly, if the given operator is "*" and the two numbers are 2 and 5.
Similarly, if the given operator is "-" and the two numbers are 10 and 9.
Sample Input 1
3 + 5
Sample Output 1
8
Sample Input 2
2 * 5
Sample Output 2
input will be single line only
3. Given a string and substring, write a method that returns number of occurrences of substring in the string. Assume that both are case-sensitive. You may need to use library function here.
Expected input and output
HowManyOccurrences("do it now", "do") → 1
HowManyOccurrences("empty", "d") → 0
4. Write a program in C# Sharp to count a total number of duplicate elements in an array.
Test Data :
Input the number of elements to be stored in the array :3
Input 3 elements in the array
1. Given a sequence of brackets, write a method that checks if it has the same number of opening and closing brackets.
Expected input and output
CheckBracketsSequence("((()))") → true
CheckBracketsSequence("()(())(") → false
CheckBracketsSequence(")") → false
2. Given a string, write a method that counts its number of words. Assume there are no leading and trailing whitespaces and there is only single whitespace between two consecutive words.
Expected input and output
NumberOfWords("This is sample sentence") → 4
NumberOfWords("OK") → 1
1. Write a C# Sharp program to find the sum of first 10 natural numbers. Go to the editor
Expected Output :
The first 10 natural number is :
1 2 3 4 5 6 7 8 9 10
The Sum is : 55
2. Write a program in C# Sharp to make such a pattern like a pyramid with numbers increased by 1.
1
2 3
4 5 6
7 8 9 10
Write a program in C# Sharp to calculate and print the Electricity bill of a given customer. The customer id., name and unit consumed by the user should be taken from the keyboard and display the total amount to pay to the customer. The charge are as follow :
Unit Charge/unit
upto 199 @1.20
200 and above but less than 400 @1.50
400 and above but less than 600 @1.80
600 and above @2.00
If bill exceeds Rs. 400 then a surcharge of 15% will be charged and the minimum bill should be of Rs. 100/-
Test Data :
1001
James
800
Expected Output :
Customer IDNO :1001
Customer Name :James
unit Consumed :800
Amount Charges @Rs. 2.00 per unit : 1600.00
Surchage Amount : 240.00
Net Amount Paid By the Customer : 1840.00
Write a C# Sharp program to read temperature in centigrade and display a suitable message according to temperature state below :
Temp < 0 then Freezing weather
Temp 0-10 then Very Cold weather
Temp 10-20 then Cold weather
Temp 20-30 then Normal in Temp
Temp 30-40 then Its Hot
Temp >=40 then Its Very Hot
Test Data :
42
Expected Output :
Its very hot.
2. Write a C# Sharp program that takes a number and a width also a number, as input and then displays a triangle of that width, using that number.
Test Data
Enter a number: 6
Enter the desired width: 6
Expected Output :
666666
66666
6666
666
66
6
1. Write a method that prints 10 by 10 multiplication table. Remember about readibility (spaces in the right place).
Expected input and output
1 2 3 4 5 6 7 8 9 10
2 4 6 8 10 12 14 16 18 20
3 6 9 12 15 18 21 24 27 30
4 8 12 16 20 24 28 32 36 40
5 10 15 20 25 30 35 40 45 50
6 12 18 24 30 36 42 48 54 60
7 14 21 28 35 42 49 56 63 70
8 16 24 32 40 48 56 64 72 80
9 18 27 36 45 54 63 72 81 90
10 20 30 40 50 60 70 80 90 100