Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package ru.tn.courses.ofefelov.v1.task1.subtask1;

public class Subtask_1 {
public static void main(String[] args) {
int[] massive = {1, 2, 3, 4, 5};
int k = 2;
int summ = 0;
for (int counter = 0; counter < massive.length; counter++) {
if (massive[counter] % k == 0) {
summ += massive[counter];
}
}
System.out.println(summ);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package ru.tn.courses.ofefelov.v1.task1.subtask1;

import java.util.Scanner;

public class Subtask_2 {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);

System.out.println("Введите длину очереди n:");

int n = scanner.nextInt();
double[] t = new double[n];
double[] c = new double[n];

System.out.println("Введите время обслуживания i покупателя:");

for (int i = 0; i < n; i++) {
t[i] = scanner.nextDouble();
if (i == 0) {
c[i] = 0;
} else {
c[i] = c[i - 1] + t[i - 1];
}
}

System.out.println("Введите пребывания i покупателя в очереди:");
for (int i = 0; i < n; i++) {
System.out.println(i + 1 + " покупатель : " + c[i] + " единиц времени в очереди");
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package ru.tn.courses.ofefelov.v1.task1.subtask1;

import java.util.Scanner;

public class Subtask_3 {
public static void main(String[] args) {
int[] a, b, c;
Scanner scanner = new Scanner(System.in);

System.out.println("Введите длину последовательностей n:");

int n = scanner.nextInt();
a = new int[n];
b = new int[n];

System.out.println("Введите последовательность a:");
for (int i = 0; i < n; i++) {
a[i] = scanner.nextInt();
}

System.out.println("Введите последовательность b:");
for (int i = 0; i < n; i++) {
b[i] = scanner.nextInt();
}

System.out.println("Новая последовательность без нового массива:");
for (int i = 0, j = 0; i < n && j < n; j++) {
while (i < n && a[i] <= b[j]) {
System.out.println(a[i++]);
}
System.out.println(b[j]);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
package ru.tn.courses.ofefelov.v1.task1.subtask2;

public class Computer {
private String name;

private String CPU;

private String RAM;

private String harddrive;

private double price;

private Type type;

public Computer(String name, String CPU, String RAM, String harddrive, double price, Type type) {
this.name = name;
this.CPU = CPU;
this.RAM = RAM;
this.harddrive = harddrive;
this.price = price;
this.type = type;
}

public Type getType() {
return type;
}

public void setType(Type type) {
this.type = type;
}

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

public String getCPU() {
return CPU;
}

public void setCPU(String CPU) {
this.CPU = CPU;
}

public String getRAM() {
return RAM;
}

public void setRAM(String RAM) {
this.RAM = RAM;
}

public String getHarddrive() {
return harddrive;
}

public void setHarddrive(String harddrive) {
this.harddrive = harddrive;
}

public double getPrice() {
return price;
}

public void setPrice(double price) {
this.price = price;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package ru.tn.courses.ofefelov.v1.task1.subtask2;

public class OnlineShop implements PriceCalculator{
private int percent = 20;
public String sellComputer(Computer comToSell){
return "Computer " + comToSell.getType() + " is selling for " + calculatePrice(percent, comToSell);
}
@Override
public double calculatePrice(int percent, Computer comp) {
double priceToSell = comp.getPrice() + comp.getPrice() / 100 * percent;
return priceToSell;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package ru.tn.courses.ofefelov.v1.task1.subtask2;

public interface PriceCalculator {
public double calculatePrice(int percent, Computer comp);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package ru.tn.courses.ofefelov.v1.task1.subtask2;

public class Subtask_1 {
public static void main(String[] args) {
Computer computer = new Computer("Comp1", "intel", "1000", "kingston", 2000, Type.DESKTOP);
OnlineShop onlineShop = new OnlineShop();
System.out.println(onlineShop.sellComputer(computer));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package ru.tn.courses.ofefelov.v1.task1.subtask2;

public enum Type {
DESKTOP, LAPTOP
}