Home / Expert Answers / Computer Science / please-code-in-java-programming-language-nbsp-nbsp-nbsp-nbsp-here-are-some-given-class-i-pa644

(Solved): Please code in Java Programming Language         Here are some given Class: I ...



Please code in Java Programming Language

 

Question paper (build 07.05.20.19)
Zoom
E
(3 Point)
Design and code a class Fan that holds information about a Fan.
-price:do

Question paper (build 07.05.20.19)
Zoom
E
4 of 4
+void fl(List<Fan> a, String code)
+int 12(List<Fan> a, double price)
+void

 

 

Question paper (build 07.05.20.19)
Zoom
E
Add more how many Fan: 1
Fan code: FF2012
Fan price: 65.0
Enter test function (1-f1

 

Here are some given Class:

IFan.class:

***********************************************************

import java.util.List;

// 
// Decompiled by Procyon v0.5.36
// 

public interface IFan
{
    void f1(final List<Fan> p0, final String p1);
    
    int f2(final List<Fan> p0, final double p1);
    
    void f3(final List<Fan> p0, final double p1);
}

***********************************************************************************************

Main.class:

***********************************************************************************************

import java.util.ArrayList;
import java.io.Reader;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Iterator;
import java.util.List;

// 
// Decompiled by Procyon v0.5.36
// 

public class Main
{
    public static void OutputList(final List<Fan> c) {
        for (final Fan x : c) {
            System.out.printf("%-15s%-10.2f\n", x.getCode(), x.getPrice());
        }
    }
    
    public static void main(final String[] args) throws Exception {
        final BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        final List<Fan> a = new ArrayList<Fan>();
        System.out.print("Add more how many Fan: ");
        for (int n = Integer.parseInt(in.readLine()), i = 0; i < n; ++i) {
            System.out.println("");
            System.out.print("Fan code: ");
            final String code = in.readLine();
            System.out.print("Fan price: ");
            final double price = Double.parseDouble(in.readLine());
            a.add(new Fan(code, price));
        }
        a.add(0, new Fan("FS21", 70.0));
        a.add(1, new Fan("KS20", 68.0));
        a.add(2, new Fan("FF12", 52.0));
        System.out.println("");
        System.out.print("Enter test function (1-f1;2-f2;3-f3): ");
        final int c = Integer.parseInt(in.readLine());
        final IFan j = (IFan)new MyFan();
        double givenPrice = 0.0;
        String givenCode = "";
        if (c == 1) {
            System.out.print("Enter given Fan code: ");
            givenCode = in.readLine();
        }
        else if (c == 2 || c == 3) {
            System.out.print("Enter given Fan price: ");
            givenPrice = Double.parseDouble(in.readLine());
        }
        System.out.println("");
        System.out.println("OUTPUT:");
        switch (c) {
            case 1: {
                j.f1(a, givenCode);
                OutputList(a);
                break;
            }
            case 2: {
                System.out.println(j.f2(a, givenPrice));
                break;
            }
            case 3: {
                j.f3(a, givenPrice);
                OutputList(a);
                break;
            }
        }
    }
}

********************************************************************************************************

 

 

Question paper (build 07.05.20.19) Zoom E (3 Point) Design and code a class Fan that holds information about a Fan. -price:double -code:String +Fan() Fan +Fan(code:String.price:double) +getCode(): String +getPrice():double +setCode(code:String):void +setPrice(price:double):void The interface IFan is given (DO NOT EDIT THIS ONE). Design and code a class coded MyFan which will implement interface IFan and complete 3 methods which were declared in IFan: +100% Where: 1. getCode():String-return code of a Fan 2. getPrice():double-return price of a Fan 3. setPrice(price:double):void - set current price to a given price 4. setCode(code:String):void - set curent code to a given code Type here to search E 2 Cose 4:19 PM ENG 8/30/2019 I P Question paper (build 07.05.20.19) Zoom E 4 of 4 +void fl(List a, String code) +int 12(List a, double price) +void (List a, double price) FS Paper No: 6 Fan code . Method named f1: remove all Fans in the list "a" which code start with the given code. Method named f2: count and return the number of Fan in the list "a" which price is less than or equals to given price. KS20 Given some data which is added to list "a" in the Main already: FF12 <> IFan Method named f3: move all fans which are in the list "a" and have price is greater than or equals to given price to beginning of the list (in the same order of original list), other fans are unchanged. + 100% Type here to search MyFan Fan price 70 68 52 E 2 ENG I Cose 4:20 PM 8/30/2019 P Question paper (build 07.05.20.19) Zoom E Add more how many Fan: 1 Fan code: FF2012 Fan price: 65.0 Enter test function (1-f1;2-f2;3-f3): 1 Enter given Fan code: FF OUTPUT: FS21 KS20 5 of 5 Paper No: 6 Add more how many Fan: 1 Fan code: FF2012 Fan price: 65.0 OUTPUT: FS21 KS20 FF2012 FF12 70.00 68.00 Enter test function (1-f1;2-f2;3-13): 3 Enter given Fan price: 65 + 100% Type here to search 70.00 68.00 65.00 52.00 Add more how many Fan: 1 Fan code: FF2012 Fan price: 65.0 Enter test function (1-f1;2-f2;3-13): 2 Enter Enter given Fan price: 65 OUTPUT: 2 E At e 2 ENG I Close 4:20 PM 8/30/2019 P


We have an Answer from Expert

View Expert Answer

Expert Answer


Main.java // importing libraries import java.util.ArrayList; import java.io.Reader; import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.Iterator; import java.util.List; // driver code public class Main { // prints t
We have an Answer from Expert

Buy This Answer $5

Place Order

We Provide Services Across The Globe