Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

C# Programming 25. Write conditional expressions to perform the following tests:

ID: 3890858 • Letter: C

Question

C# Programming

25. Write conditional expressions to perform the following tests: a. When amountowed is greater than 1000.00, display an overdue message. b. When amountOfRain is greater than 5 inches, add 5 to total. When it is between 3 and 5 inches, add 3 to total. When it is less than 3 inches, add 1 to total. c. When middleInitial is equal to the character z, display message "You're one in a thousand"; otherwise, check to see if it is equal to the character a'. When it is equal to the character a, display the message "You have a common initial". d. When balance>100 and transaction

Explanation / Answer

NOTE: statements in BOLD are the required conditionals for the given questions.

a. C# Program

using System;

class Program
{
   static void Main(string[] args)
   {
       //variable to hold the amount owed
       double amountOwed;

       //displaying info
       Console.WriteLine("Enter the amount owed ");

       //getting input from the user
       amountOwed=Convert.ToDouble(Console.ReadLine());


       //checking for amountOwed greater than 1000.00
       if (amountOwed > 1000.00)
           Console.WriteLine("Amount owed is greater than 1000.00");

      
   }
}

b. C# Program

using System;

class Program2
{
   static void Main(string[] args)
   {
       //variable to hold the amount of rain, total
       double amountOfRain,total=0;
      
       //diplaying info
       Console.WriteLine("Enter the amount of rainfall");

       //getting input from the user
       amountOfRain=Convert.ToDouble(Console.ReadLine());

       //checking for rain greater than 5
       if (amountOfRain > 5)
           total=total+5;
      
       //checking for rain greater than 3 and lesser than 5
       if (amountOfRain >=3 && amountOfRain <=5)
           total=total+3;

       // checking for rainfall lesser than 3
       if(amountOfRain < 3)
           total=total+1;

       Console.WriteLine("value of total is "+total);
      
   }
}

c.C# program

using System;

using System;

class Program3
{
   static void Main(string[] args)
   {
       //variable to storing the initial
       char middleInitial;
      

       //displaying info
       Console.WriteLine("Enter the middle initial ");

       //getting input from the user
       middleInitial=Console.ReadKey().KeyChar;

       //checking for initial to z
       if (middleInitial == 'z')
           Console.WriteLine(" You're one in a thousand");

       //checking for initial to a
       else if (middleInitial == 'a')

  
           Console.WriteLine(" You have a common initial");
       else
           {
           }

               
   }
}

d. C# Program

using System;

class Program4
{
   static void Main(string[] args)
   {

       //variable for balance, transaction
       double balance,transaction;

       //displaying info
       Console.WriteLine("Enter the balance ");

       //getting input from the user
       balance=Convert.ToDouble(Console.ReadLine());

       //displaying info
       Console.WriteLine("Enter the transaction ");

       //getting input from the user
       transaction=Convert.ToDouble(Console.ReadLine());

       //checking for balance greater than 100 and transaction less than 50
       if(balance > 100 && transaction <50)
           balance=balance-transaction;

       //checking for balance less than 100
       if(balance <100)
           balance=balance+transaction;

       Console.WriteLine("Transaction is " + transaction);
       Console.WriteLine("Balance is "+ balance);
               
   }
}