-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathProgram.cs
More file actions
78 lines (64 loc) · 2.84 KB
/
Program.cs
File metadata and controls
78 lines (64 loc) · 2.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Function_Matrizes
{
internal class Program
{
static void Main(string[] args)
{
// Exemplo feito em aula (Cadastro de clientes, produtos e preços)
// Matrizes são usadas para organizar e manipular dados de maneira eficiente em
// uma estrutura tabular. Elas permitem armazenar informações relacionadas em
// um formato de grade, o que facilita o acesso rápido a elementos específicos.
string[] nomeCliente;
int[] quantProd;
double[] precoProdTotal;
double[][] precoProd;
string[][] nomeProd;
Console.WriteLine("Quantos clientes deseja cadastrar? ");
int quant = Convert.ToInt32(Console.ReadLine());
nomeCliente = new string[quant];
quantProd = new int[quant];
precoProd = new double[quant][];
nomeProd = new string[quant][];
for (int i = 0; i < quant; i++)
{
Console.WriteLine("\r\nDigite o nome do Cliente:");
nomeCliente[i] = Console.ReadLine();
Console.Write("Digite quantos produtos este cliente quer comprar: ");
quantProd[i] = Convert.ToInt32(Console.ReadLine());
precoProd[i] = new double[quantProd[i]];
nomeProd[i] = new string[quantProd[i]];
for (int j = 0; j < quantProd[i]; j++)
{
Console.Write("\r\nDigite o NOME do produto do cliente: " + nomeCliente[i]);
nomeProd[i][j] = Console.ReadLine();
Console.Write("Digite o PREÇO do produto do cliente: " + nomeCliente[i]);
precoProd[i][j] = Convert.ToDouble(Console.ReadLine());
}
}
// Mostrar os dados
Console.Write("Carregando.");
for (int i = 0; i < 60; i++)
{
System.Threading.Thread.Sleep(30);
Console.Write(".");
}
Console.WriteLine("");
for (int i = 0; i < quant; i++)
{
Console.WriteLine("Cliente: " + nomeCliente[i]);
Console.WriteLine("Este cliente comprou " + quantProd[i] + " produtos.");
for (int j = 0; j < quantProd[i]; j++)
{
Console.WriteLine("\r\nO " + (j + 1) + "º produto é: " + nomeProd[i][j]);
Console.WriteLine("O " + (j + 1) + "º produto tem o valor de: " + precoProd[i][j]);
}
// Calcular o valor total das compras aqui, se necessário
}
}
}
}