Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.company.ppj_25;
- import java.io.FileInputStream;
- import java.io.IOException;
- import java.sql.SQLOutput;
- public class Main {
- public static void main(String[] args) {
- int[] array = new int[5*4];
- try {
- FileInputStream fileInputStream = new FileInputStream("P:/knopers/PPJ/input/z2_s18660.bin");
- int tmp = 0;
- for(int i = 0; tmp != -1; i++) {
- tmp = fileInputStream.read();
- if(tmp != -1) {
- array[i] = tmp;
- System.out.println(array[i]);
- }
- }
- fileInputStream.close();
- // Zapisanie do tablicy wszystkich informacji
- }catch(IOException e){
- System.out.println(e);
- }
- System.out.println();
- int[][] arrayByteValues = new int[5][4];
- for(int i = 0, k = 0; i < 5; i++){
- for(int j = 0; j < 4; j++, k++){
- arrayByteValues[i][j] = array[k];
- }
- }
- int[] arrayConverted = new int[5];
- for(int i = 0; i < 5; i++){
- for(int j = 0; j < 4; j++){
- arrayConverted[i] += arrayByteValues[i][j] << 8*j;
- }
- }
- System.out.println();
- int calkowita = 0;
- int ulamkowa = 0;
- boolean foundCal = false;
- for(int i = 0; i < arrayConverted.length; i++){
- System.out.println(arrayConverted[i]);
- if(arrayConverted[i] < 255) {
- if (foundCal == false) {
- calkowita = arrayConverted[i];
- foundCal = true;
- }else{
- ulamkowa = arrayConverted[i];
- }
- }
- }
- System.out.println();
- System.out.println("Twoj wynik z 3 kolokwium to " + calkowita + "." + ulamkowa);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement