Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- //import java.text.DecimalFormat;
- public class loopers
- {
- public static void main(String[] Args)
- {
- Scanner a=new Scanner(System.in);
- int z=Integer.parseInt(a.nextLine());
- //DecimalFormat format = new DecimalFormat("#.#");
- //format.setDecimalSeparatorAlwaysShown(false);
- double emax=-100000000.00;
- double emin=100000000.00;
- double omax=-100000000.00;
- double omin=100000000.00;
- double u=0;
- double p=0;
- for(int i=1;i<=z;i++)
- {
- double y=Double.parseDouble(a.nextLine());
- if(i%2==0)
- {
- p=p+y;
- if(y>emax)
- emax=y;
- if(y<emin)
- emin=y;
- }
- else
- {
- u=u+y;
- if(y>omax)
- omax=y;
- if(y<omin)
- omin=y;
- }
- }
- System.out.printf("Oddsum=%.0f,",u);
- if(omax==-100000000.00){
- System.out.println("Oddmin=No,");
- System.out.println("Oddmax=No,");
- }else{System.out.printf("Oddmin=%.0f,",omin);
- System.out.printf("Oddmax=%.0f,",omax);}
- System.out.printf("Evensum=%.0f,",p);
- if(emax==-100000000.00){
- System.out.println("Evenmin=No,");
- System.out.println("Evenmax=No,");
- }else{System.out.printf("Evenmin=%.0f,",emin);
- System.out.printf("Evenmax=%.0f,",emax);}
- //System.out.println("Oddmin="+(decimalFormat.format(omin))+","); вади грешка
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement