A
A
Andrey Rudenko2021-09-07 17:39:41
Java
Andrey Rudenko, 2021-09-07 17:39:41

Error in code "java: class, interface, or enum expected" What is the problem?

The code does not compile, I do not understand what the problem is, tell me please.

package com.andrei;
import java.io.*;
public class Parts{
    String name;
    int age;
    double price;
    int date;

    public Parts(String name){
        this.name = name;
    }

    public void empAge(int empAge){
        age =  empAge;
    }

    public void empPrice(double empPrice){
        price = empPrice;
    }

    public void empDate(int empDate){
        date = empDate;
    }

    public void printParts(){
        System.out.println("Назва запчастини:"+ name );
        System.out.println("Кількість:" + age );
        System.out.println("Ціна:" + price );
        System.out.println("Термін зберігання:" + date);
    }
}

import java.io.*;
public class PartsTest{

    public static void main(String args[]){

        Parts empOne = new Parts("Диски");
        Parts empTwo = new Parts("Лобовое стекло");


        empOne.empAge(11);
        empOne.empPrice(11500.53);
        empOne.empDate(48);
        empOne.printParts();

        empTwo.empAge(3);
        empTwo.empPrice(15000.35);
        empTwo.empDate(72);
        empTwo.printParts();
    }
}

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question