Write a
Your program must use a function that takes 4 parameters (2 for the feet and inches of the first length, and 2 for the feet an inches of the second length). The function must return a string with the answer.
below is my code and l would like it to use a function that takes 4 parameters and also the function must return a string with the answer.
using System;
public class main
{
public static void Sum(int f1, int i1, int f2, int i2)
{
int ftotal;
int itotal;
ftotal = f1 + f2;
itotal = i1 + i2;
while (itotal >= 12)
{
itotal = itotal - 12;
ftotal = ftotal + 1;
}
Console.WriteLine("\n The total feet is "); Console.WriteLine(ftotal);
Console.WriteLine("\n The total inches is "); Console.WriteLine(itotal);
}
public static void Main()
{
Console.Write("Enter feet for distance 1: ");
int f1 = Convert.ToInt32(Console.ReadLine());
Console.Write("Enter inches for distance 1: ");
int i1 = Convert.ToInt32(Console.ReadLine());
Console.Write("Enter feet for distance 2: ");
int f2 = Convert.ToInt32(Console.ReadLine());
Console.Write("Enter inches for distance 2: ");
int i2 = Convert.ToInt32(Console.ReadLine());
Sum(f1, i1, f2, i2);
}
}
Trending nowThis is a popular solution!
Step by stepSolved in 3 steps with 3 images
- Write a function that will draw n squares inside each other. The function will receive n (number of squares) and side (the side of the most inner or outer square in pixels) through its parameters. Call and test this function from a main program.arrow_forwardWrite a program that simulates coin tossing. For each toss of the coin the program should print Heads or Tails. Let the program toss the coin 100 times and count the number of times each side of the coin appears. Print the results. The program should call a separate function flip that takes no arguments and return 0 for tails and 1 for heads. flip depends on the rand function to simulate coin toss [Note: if the program realistically simulates the coin tossing, then each side of the coin should appear approximately half the time for a total of approximately 50 heads and 50 tails].arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education