Great Deal! Get Instant $10 FREE in Account on First Order + 10% Cashback on Every Order Order Now

CSC 210 PROJECT 9 FALL 2020 Project 9 Instructions WHAT TO SUBMIT ● JAVA Files: ○ CONSTANT.java (provided – no need to make change), ○ StandarDevAndHist.java, (30 points) ○ DecAndBin.java (provided –...

1 answer below »
CSC 210 PROJECT 9
FALL 2020


Project 9 Instructions
WHAT TO SUBMIT
● JAVA Files:
○ CONSTANT.java (provided – no need to make change),
○ StandarDevAndHist.java, (30 points)
○ DecAndBin.java (provided – no need to make change),
○ Binary.java (30 points)
Please make sure you remove package in your java file! It is required for auto-grading.


Decimal And Binary conversion [30 points]
Problem Description:

1. Create a class for Binary as used in DecAndBin class.
2. Implement all the below listed concepts in your class.

Execution Results (when a “decAndBinTest.txt” file was given as below)
C:\Users\ilmiy\.jdks\openjdk XXXXXXXXXXbin\java.exe "-javaagent:C:\Program Files\JetBrains\IntelliJ IDEA Community
Edition XXXXXXXXXXlib\idea_rt.jar=53281:C:\Program Files\JetBrains\IntelliJ IDEA Community Edition XXXXXXXXXXbin" -
Dfile.encoding=UTF-8 -classpath C:\Users\ilmiy\IdeaProjects\project5\out\production\project5 DecAndBin
Enter n:5
XXXXXXXXXX
Enter binary:111
7
true
XXXXXXXXXX
XXXXXXXXXX
XXXXXXXXXX
XXXXXXXXXX
XXXXXXXXXX
XXXXXXXXXX
7
5
255
25
CSC 210 PROJECT 9
FALL 2020
Contents of “decAndBinTest.txt”

1 1
1 3
1 4
1 127
1 128
1 5
2 111
2 101
XXXXXXXXXX
XXXXXXXXXX
You can read about Decimal to Binary conversion and the other way around (Please check the lecture)
https:
www.electronics-tutorials.ws
inary
in_2.html
https:
www.binaryhexconverter.com/decimal-to-binary-converter

Standard Deviation and Histogram [30 points]

You already know how to calculate sum and mean. You can extend this to the data from a file (data2.txt)
Calculate Standard Deviation (check the lecture & https:
www.mathsisfun.com/data/standard-deviation-
formulas.html )

Here is the execution result using data2.txt
Total count is 100
Sum of all the data is 48050

The average of the data is 480.5

The standard deviation of the data is XXXXXXXXXX
1 - 100 :***********
XXXXXXXXXX :******

XXXXXXXXXX :***********

XXXXXXXXXX :*****************

XXXXXXXXXX :******
https:
www.electronics-tutorials.ws
inary
in_2.html
https:
www.binaryhexconverter.com/decimal-to-binary-converte
https:
www.mathsisfun.com/data/standard-deviation-formulas.html
https:
www.mathsisfun.com/data/standard-deviation-formulas.html
CSC 210 PROJECT 9
FALL 2020
XXXXXXXXXX :*************

XXXXXXXXXX :*********

XXXXXXXXXX :**********

XXXXXXXXXX :***********

XXXXXXXXXX :******


    Project 9 Instructions
    ○ StandarDevAndHist.java, (30 points)
    Decimal And Binary conversion [30 points]
    1. Create a class for Binary as used in DecAndBin class.
    Standard Deviation and Histogram [30 points]
Answered Same Day Dec 14, 2021 CSC 210

Solution

Valupadasu answered on Dec 14 2021
151 Votes
Binary.java
Binary.java
public class Binary {
    int dec;
    int[] bin;
    public Binary() {
        dec = 0;
        bin = new int[CONSTANT.BIT_SIZE];
    }
    public Binary(int dec) {
        this.dec = dec;
        bin = convertDecToBin(dec);
    }
    
 Fill in the contructor below
    
 Make sure that dec value to be properly calculated
    public Binary(int[] bin) {
        this.bin = bin;
        dec = convertDecToBin(bin);
    }
    
 Fill in the contructor below
    
 Make sure that dec value to be properly calculated
    public Binary(String binS) {
        int binA
[] = new int[binS.length()];
        
        for(int i=0; i < binS.length() ; i++) {
            binA
[i] = binS.charAt(i);
        }
        dec = convertDecToBin(binA
);
    }
    public int getDec() {
        return dec;
    }
    
 convert the bin a
ay to decimal value
    private int convertDecToBin(int[] bin) {
        int digit, power, sum = 0;
        for (int i = bin.length -1, j = 0 ; i >= 0 && j < bin.length; i--, j++) {
            digit = bin[i] - 48; 
 converting char to equivalent int
            power = (int) Math.pow(2, j);
            sum = sum + (digit * power);
   ...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here