TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Giovanbattista Barra
NA
98
18.4k
Console Application: Programming a Warehouse
Nov 20 2018 12:28 PM
Hallo dear Team,
here I explain shortly how the programm should work:
I have to prpgramm a Warehouse with 75 boxes and I need to calculate the volume of them each time the user inserts info like height, width and length of each box.
Anyway I wrote in red what it doesnt work out
using System;
namespace Lagerverwaltung
{
class Program
{
private const byte kisteNrMin = 1;
private const byte kisteNrMax = 75;
struct Box
{
public int idBox;
public int width;
public int height;
public int length;
public int status;
}
static int Volume(Box boxes)
{
int volValue;
volValue = boxes.length * boxes.width * boxes.height;
return volValue;
}
static void Eingeben(Box[] boxes)
{
for (int index = 0; index < 75; index++)
{
if (boxes[index].status == 0)
{
Console.Write("Insert the height {0} of the box: ", boxes[index].idBox);
boxes[index].height = Convert.ToInt32(Console.ReadLine());
Console.Write("Insert the width {0} of the box: ", boxes[index].idBox);
boxes[index].width = Convert.ToInt32(Console.ReadLine());
Console.Write("
Insert the
die length {0}
of the box
: ", boxes[index].idBox);
boxes[index].width = Convert.ToInt32(Console.ReadLine());
boxes[index].status = 1;
//here when I call the method volume doesnt work - i get 0 as result - why?
Console.WriteLine("The volume of the box is {0}", Volume(boxes[index]));
break;
}
else
{
Console.WriteLine("The box {0} is reserved.", boxes[index].idBox);
}
}
}
static void Delete(Box[] boxes)
{
Console.WriteLine("Which Box would u like to cancel? Please insert a number from 1 - 75.");
int number = Convert.ToInt32(Console.ReadLine()) - 1;
if (number <= 75 && number >= 0)
{
Console.WriteLine("The box was cancelled.");
}
//dont delete the same box you cancelled before
//that's why, make a difference (for example: you delete box number 5, thats's why the programm must calculate 74-1 and so on - here I try but it doesnt work)
else if (number == boxes[number].idBox)
{
Console.WriteLine("The box was already cancelled before");
}
}
static void Main(string[] args)
{
int insert = 0;
Box[] storeroom = new Box[75];
for (int index = 0; index < 75; index++)
{
storeroom[index].idBox = index + 1;
}
while (insert != 3)
{
Console.WriteLine("\nPlease chhose a programm:\n");
Console.WriteLine("[1] Insert Box");
Console.WriteLine("[2] Cancel Box");
Console.WriteLine("[3] End Program\n");
insert = Convert.ToInt32(Console.ReadLine());
switch (insert)
{
case 1:
Eingeben(storeroom);
break;
case 2:
Delete(storeroom);
break;
case 3:
break;
}
}
}
}
}
I hope you can really help me and thank u in advance.
Best regards
Giovanni
Reply
Answers (
4
)
how to read json data from body tag
ball clock application in wpf c#