Day 2: Operators Solution in C# & Python | 30 Days of Code

CodeWithHonor
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:

  1. Declares a variable mealCost of type double and assigns it the value of the first line of input.
  2. Declares a variable tipPercent of type int and assigns it the value of the second line of input.
  3. Declares a variable taxPercent of type int and assigns it the value of the third line of input.
  4. Calculates the total cost of the meal by adding the tip and tax amounts to the meal cost.
  5. Rounds the total cost to the nearest integer using the Math.Round() method.
  6. 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…

--

--