Как написать эту функцию с помощью математики?
Итак, я получил это задание, которое требует от меня использовать классы, если это объявление для циклов(если это необходимо).
1.Create a class called "Nail" that has variables for storing length and thickness. The store has three types of Nails. Find which nails are the longest and the thickest.
Итак, я выполнил первое задание. Теперь на втором я заблудился:
2.Create a class called "Box" that stores variables for length, width and height of the box(already did this). You need to construct the box in which nails are hammered in every 10 cm if their length is 8 cm or every 15 cm if their length is 10 cm. Calculate how many nails are needed?
3.Add some variables in the "Box" class to the Insert () method, which allows you to change the size of the box - length, width and height. Of which nails will be needed the most if we increase the box height "x" cm?
Мне действительно нужна помощь с этим я заблудился...Мне нужно вычислить площадь коробки, по крайней мере, так я думаю, ИДК, может быть, есть другой способ вычислить все это...
Итак вот мой код;
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace tss { class Nail //Dont pay attention to weigth { private int length, thickness, weight; public Nail(int naillength, int nailthickness, int nailweight) { length = naillength; thickness = nailthickness; weight = nailweight; } public int TakeLength() { return length; } public int TakeThickness() { return thickness; } public int TakeWeight() { return weight; } } class Box { private int length, wideness, height; public Box(int boxlength, int boxwideness, int boxheight) { length = boxlength; wideness = boxwideness; height = boxheight; length = int.Parse(Console.ReadLine()); wideness = int.Parse(Console.ReadLine()); height = int.Parse(Console.ReadLine()); } public int TakeLength() { return length; } public int TakeWideness() { return wideness; } public int TakeHeight() { return height; } } class Calculations { static void Main(string[] args) { Nail p1; p1 = new Nail(8, 5, 4); Console.WriteLine("1st - nail length: {0,3:d} cm \n1st - nail thickness {1, 4:d} mm \n1st - nail weigth: {0,5:d} g", p1.TakeLength(), p1.TakeThickness(), p1.TakeWeight()); Nail p2; p2 = new Nail(10, 6, 5); Console.WriteLine("2nd - nail length: {0,3:d} cm \n2nd - nail thickness: {1, 4:d} mm \n2nd - nail weigth: {0,5:d} g", p2.TakeLength(), p2.TakeThickness(), p2.TakeWeight()); Nail p3; p3 = new Nail(12, 7, 6); Console.WriteLine("3st - nail length: {0,5:d} cm \n3 - nail thickness: {1, 4:d} mm \n3 - nail weigth: {0,5:d} g", p3.TakeLength(), p3.TakeThickness(), p3.TakeWeight()); /// This finds the biggest value Console.WriteLine(Math.Max(Math.Max(p1.TakeLength(), p2.TakeLength()), p3.TakeLength())); Console.WriteLine(Math.Max(Math.Max(p1.TakeThickness(), p2.TakeThickness()), p3.TakeThickness())); Box d1; d1 = new Box(1, 1, 1); Console.WriteLine("Box length: {0,5:d} cm \nBox wideness: {1, 4:d} cm \nBox height: {0,5:d}cm", d1.TakeLength(), d1.TakeWideness(), d1.TakeHeight()); } } } }
Я действительно не нашел способа, как рассчитать, сколько гвоздей мне нужно..
Что я уже пробовал:
Попробовать все. Мне просто нужна помощь в том, как я должен построить эту программу.