Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class lekarstwa {
- static private String[] nazwa;
- static private double[] cena;
- static private double[] refundacja;
- lekarstwa(String[] nazwa, double[] cena, double[] refundacja){
- this.nazwa = new String[nazwa.length];
- this.cena = new double[cena.length];
- this.refundacja = new double[refundacja.length];
- for(int i=0;i<nazwa.length;i++){
- char[] znaki = nazwa[i].toCharArray();
- String poprawione = Character.toString(znaki[0]).toUpperCase();
- int lk = 0;
- for(char a:znaki){
- if(lk>0) poprawione+= Character.toString(a).toLowerCase();
- lk++;
- }
- this.nazwa[i] = poprawione;
- }
- for(int i=0;i<cena.length;i++){
- this.cena[i] = cena[i];
- }
- for(int i=0;i<refundacja.length;i++){
- this.refundacja[i] = refundacja[i];
- }
- }
- public static double Cena(String lek, boolean ubezpieczony){
- int lk=0;
- for(String a:nazwa){
- if(a.equals(lek)) break;
- lk++;
- }
- if(ubezpieczony==true) return cena[lk]*(1-refundacja[lk]);
- else return cena[lk];}
- public static double kosztCalkowity(){
- double suma=0;
- for(double a:cena){
- suma+=a;
- }
- return suma;}
- public static void wyswietl(int index_leku){
- System.out.println(nazwa[index_leku]+", cena: "+cena[index_leku]+", refundacja: "+(refundacja[index_leku])*100+"%");}
Add Comment
Please, Sign In to add comment