Академический Документы
Профессиональный Документы
Культура Документы
Отчет
по лабораторной работе № 1
Выполнил:
студент 2 курса группы 6.04.122.010.19.1
факультета ЭИ
Бугай И.С.
Проверил:
доцент кафедры ИС
к.т.н., с.н.с. Парфенов Ю.Э.
СОДЕРЖАНИЕ
Задание 1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
Задание 2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
Выводы . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
3
Задание 1
Условие задания
Разработать программу на языке С# для вывода на консоль ведомость использования
машинного времени на вычислительном центре. (Вариант 3)
using System;
public class Vidomist
{
private string cafedra;
private int hours_za_planom;
private int hours_factichno;
public Vidomist(string cafedra, int hours_za_planom, int hours_factichno)
{
this.cafedra = cafedra;
this.hours_za_planom = hours_za_planom;
this.hours_factichno = hours_factichno;
}
public string getCafedra() { return cafedra; }
public int getHours_za_planom() { return hours_za_planom; }
public int getHours_factichno() { return hours_factichno; }
public int hours() { return hours_za_planom - hours_factichno; }
public int procents() { return (hours_za_planom - hours_factichno) *100/ hours_za_planom; }
}
namespace MainClass1
{
class Program
{
public static double sumHours_za_planom(Vidomist[] list)
{
double sum = 0;
for (int i = 0; i < list.Length; i++)
sum += list[i].getHours_za_planom();
return sum;
}
public static double sumHours_factichno(Vidomist[] list)
{
double sum = 0;
for (int i = 0; i < list.Length; i++)
sum += list[i].getHours_factichno();
return sum;
}
public static void formatPrintOrder(Vidomist[] list)
{
Console.WriteLine("_____________________________________________________________________________
___________________________________________________");
Console.WriteLine(String.Format("|{0,2} |{1,12} |{2,15} |{3,25} |{4,25} |{5,25} |", "№",
"Кафедра", "За планом, г.", "Фактично, г.", "Відхилення у г.","Відхилення у %"));
for (int i = 0; i < list.Length; i++)
{
4
Console.WriteLine("_____________________________________________________________________________
___________________________________________________");
Console.WriteLine(String.Format("|{0,2} |{1,12} |{2,15} |{3,25} |{4,25} |{5,25} |", " ",
"Разом", sumHours_za_planom(list), sumHours_factichno(list), " ", " "));
Console.WriteLine("_____________________________________________________________________________
___________________________________________________");
}
static void Main(string[] args)
{
bool program_end = false;
int count_hours = 0;
Vidomist[] VidomistList = new Vidomist[count_hours];
string cafedra;
int hours_za_planom;
int hours_factichno;
Console.OutputEncoding = System.Text.Encoding.Default;
do
{
Console.WriteLine(" Варіант 3");
Console.WriteLine("Відомість використання машинного часу");
Console.WriteLine("Натисніть 1 - аби створити нову відомість\nНатисніть 2 - щоб
показати таблицю\nНатисніть 0 - аби вийти із програми");
int n = int.Parse(Console.ReadLine());
if (n == 1)
{
Console.WriteLine("Введіть кількість записів, які ви бажаєте додати");
count_hours = int.Parse(Console.ReadLine());
VidomistList = new Vidomist[count_hours];
for (int i = 0; i < count_hours; i++)
{
Console.WriteLine("Введіть назву " + (i + 1) + "-ї кафедри");
cafedra = Console.ReadLine();
Console.WriteLine("Введіть використання часу за планом " + (i + 1) +
"-ї кафедри");
hours_za_planom = int.Parse(Console.ReadLine());
Console.WriteLine("Введіть використання часу фактично " + (i + 1) +
"-ї кафедри");
hours_factichno = int.Parse(Console.ReadLine());
Vidomist _vidomist = new Vidomist(cafedra, hours_za_planom,
hours_factichno);
VidomistList[i] = _vidomist;
}
if (n == 2)
{
formatPrintOrder(VidomistList);
5
План тестирования
Задание 2
Условие задания
Разработать программу на языке Java для вывода на консоль ведомость
использования машинного времени на вычислительном центре. (Вариант 3)
Архитектура:
class Vidomist
{
private final String cafedra;
private final int hours_za_planom;
private final int hours_factichno;
System.out.println("____________________________________________________________________________
_______________________________");
System.out.printf("|%-2s|%-18s|%-15s|%-25s|%-25s|%-15s|\n%n","№", "Кафедра", "За планом, г.",
"Фактично, г.", "Відхилення у г.","Відхилення у %");
for(int i = 0;i < list.length; i++)
{
System.out.printf("|%-2s|%-18s|%-15s|%-25s|%-25s|%-15s|\n%n", i+1,
list[i].getCafedra(),list[i].getHours_za_planom(),list[i].getHours_factichno(),list[i].hours(), list[i].procents());
}
System.out.println("____________________________________________________________________________
_______________________________");
System.out.printf("|%-2s|%-18s|%-15s|%-25s|%-25s|%-15s|\n%n", " ", "Разом",
sumHours_za_planom(list), Hours_factichno(list), " ", " ");
}
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
boolean program_end = false;
int count = 0;
Vidomist[] cactusList = new Vidomist[count];
String cafedra;
int hours_za_planom;
int hours_factichno;
do
{
System.out.println(" Варіант 3");
System.out.println("Відомість використання машинного часу");
System.out.println("Натисніть 1 - аби створити новий облік\nНатисніть 2 - щоб показати
таблицю\nНатисніть 0 - аби вийти із програми");
int n = in.nextInt();
if(n == 1)
{
System.out.println("Введіть кількість записів, які ви бажаєте додати");
count = in.nextInt();
8
Выводы