Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- package liczwystapienia;
- import java.io.File;
- import java.io.FileNotFoundException;
- import java.io.IOException;
- import java.io.PrintWriter;
- import java.util.Scanner;
- /**
- *
- * @author Darkey
- */
- public class main {
- public static void main(String[] args){
- /*
- Egzamin egz = new Egzamin(2,3);
- egz.wpiszOcene(0, 0, 4);
- egz.wpiszOcene(0, 1, 4);
- egz.wpiszOcene(0, 2, 4);
- egz.wpiszOcene(1, 0, 2);
- egz.wpiszOcene(1, 1, 2);
- egz.wpiszOcene(1, 2, 3);
- System.out.println(egz.zaliczonyEgzamin(0));
- System.out.println(egz.zaliczonyEgzamin(1));
- egz.piszDane();
- */
- }
- public void funkcja(String plik){
- int nr_zamowienia;
- String nazwa;
- double cena;
- int l_sztuk;
- try{
- Scanner sc = new Scanner(new File(plik + ".txt"));
- PrintWriter writer = new PrintWriter(new File(plik + ".wyn"));
- while(sc.hasNext()){
- nr_zamowienia = sc.nextInt();
- nazwa = sc.nextLine();
- cena = sc.nextDouble();
- l_sztuk = sc.nextInt();
- }
- }
- catch(Exception e ){
- System.out.println("XD");
- }
- }
- }
- class Egzamin{
- private float[][] oceny;
- Egzamin(int lStudentow, int lZadan){
- this.oceny = new float[lStudentow][lZadan];
- }
- public float ObliczSrednia(int student){
- float suma = 0;
- int counter = 0;
- for(int x = 0; x < oceny[student].length; x++){
- if(oceny[student][x] > 2){
- counter++;
- }
- suma = suma + oceny[student][x];
- }
- if(counter > (oceny[student].length/2))
- return 2;
- else
- return (suma / (oceny[student].length));
- }
- public boolean zaliczonyEgzamin(int student){
- float srednia = ObliczSrednia(student);
- System.out.println(srednia);
- if(srednia >= 3 ){
- return true;
- }
- else
- return false;
- }
- public void wpiszOcene(int student, int zadanie, float ocena){
- oceny[student][zadanie] = ocena;
- }
- public void piszDane(){
- for(int i = 0; i < oceny.length; i++){
- System.out.print(i + "; ");
- for(int j = 0; j < oceny[i].length; j++){
- System.out.print(oceny[i][j] + "; ");
- }
- System.out.println(ObliczSrednia(i));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement