Database System Concepts
Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
Bartleby Related Questions 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
expand button
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
Check Mark
Knowledge Booster
Background pattern image
Computer Science
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.
Recommended textbooks for you
Text book image
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education