Day 2: Operators Solution in C# & Python | 30 Days of Code
3 min readDec 23, 2022
Screenshot for those who want to take a look at the question:
Solution in C#
To solve the “Day 2: Operators” problem on HackerRank using C#, you need to write a program that reads three lines of input from the console and performs the following actions:
- Declares a variable
mealCost
of typedouble
and assigns it the value of the first line of input. - Declares a variable
tipPercent
of typeint
and assigns it the value of the second line of input. - Declares a variable
taxPercent
of typeint
and assigns it the value of the third line of input. - Calculates the total cost of the meal by adding the tip and tax amounts to the meal cost.
- Rounds the total cost to the nearest integer using the
Math.Round()
method. - Prints the total cost to the console as an integer.
Here is an example solution in C#:
using System;
namespace Operators
{
class Program
{
static void Main(string[] args)
{
// Read input
double…