Write a program which requests two lengths in feet and inches (both whole numbers) and prints the sum of the lengths in feet and inches. For example, if the lengths are 5 ft. 4 in. and 8 ft. 11 in., your program should print 14ft. 3 in. (1 ft. = 12 in.) 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.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
100%

Write a program which requests two lengths in feet and inches (both whole numbers) and prints the sum of the lengths in feet and inches. For example, if the lengths are 5 ft. 4 in. and 8 ft. 11 in., your program should print 14ft. 3 in. (1 ft. = 12 in.)

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);
    }
}

File
Edit
View
Git
Project
Build
Debug
Test
Analyze
Tools
Extensions
Window
Help
Search (Ctrl+Q)
lab3
TM
Debug
Any CPU
> lab3 -
E Live Share
Program.cs + x
Pr...
C= lab3
main
- O Main()
using System;
O references
Opublic class main
1
3
1 reference
public static void Sum(int f1, int il, int f2, int i2)
int ftotal;
int itotal;
ftotal = f1 + f2;
7
10
itotal = il + i2:
11
while (itotal >= 12)
{
12
13
14
itotal
itotal
12;
15
ftotal
ftotal + 1;
}
17
18
Console.WriteLine("\n The total feet is "); Console.Writeline(ftotal);
19
20
Console.WriteLine("\n The total inches is "); Console.Writeline(itotal);
21
22
O references
23
public static void Main()
24
25
26
Console.Write("Enter feet for distance 1: ");
27
int f1 = Convert.ToInt32(Console.ReadLine());
28
Console.Write("Enter inches for distance 1: ");
29
int il = Convert.ToInt32(Console.ReadLine());
Console.Write("Enter feet for distance 2: ");
int f2 = Convert.ToInt32(Console.ReadLine(O);
Console.Write("Enter inches for distance 2: ");
int i2 = Convert.ToInt32(Console.Readline());
Sum (f1, i1, f2, i2);|
30
31
32
33
34
35
36
82 %
No issues found
Ln: 34
Ch: 29
SPC
CRLF
O Ready
Diagnostic Tools
Toolbox
Transcribed Image Text:File Edit View Git Project Build Debug Test Analyze Tools Extensions Window Help Search (Ctrl+Q) lab3 TM Debug Any CPU > lab3 - E Live Share Program.cs + x Pr... C= lab3 main - O Main() using System; O references Opublic class main 1 3 1 reference public static void Sum(int f1, int il, int f2, int i2) int ftotal; int itotal; ftotal = f1 + f2; 7 10 itotal = il + i2: 11 while (itotal >= 12) { 12 13 14 itotal itotal 12; 15 ftotal ftotal + 1; } 17 18 Console.WriteLine("\n The total feet is "); Console.Writeline(ftotal); 19 20 Console.WriteLine("\n The total inches is "); Console.Writeline(itotal); 21 22 O references 23 public static void Main() 24 25 26 Console.Write("Enter feet for distance 1: "); 27 int f1 = Convert.ToInt32(Console.ReadLine()); 28 Console.Write("Enter inches for distance 1: "); 29 int il = Convert.ToInt32(Console.ReadLine()); Console.Write("Enter feet for distance 2: "); int f2 = Convert.ToInt32(Console.ReadLine(O); Console.Write("Enter inches for distance 2: "); int i2 = Convert.ToInt32(Console.Readline()); Sum (f1, i1, f2, i2);| 30 31 32 33 34 35 36 82 % No issues found Ln: 34 Ch: 29 SPC CRLF O Ready Diagnostic Tools Toolbox
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 3 images

Blurred answer
Knowledge Booster
Function Arguments
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education