Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static void Quiz3() {
- int N = 5;
- int []v = new int[N];
- double []t = new double[N];
- for(int i = 0; i < N; ++i) {
- v [i] = StdIn.readInt();
- t [i] = StdIn.readDouble();
- }
- for(int i = 0; i < N; ++i) {
- System.out.println(String.format("%d %f",v[i], t[i]));
- }
- //Check the too last
- int last = v.length-1;
- int plast = v.length-2;
- double Y = (double) v[plast]/v[last];
- double X = (double) t[plast]/t[last];
- System.out.println(""+Y+" "+X);
- // Y**b = X
- // b = log(X)/log(Y)
- double b = Math.log(X)/Math.log(Y);
- double a = (double) t[last]/(Math.pow(v[last],b));
- System.out.println(b);
- System.out.println(a);
- for(int i = 0; i < N; ++i) {
- System.out.println(String.format("%d %f",v[i], Math.pow(v[i],b)*a));
- }
- System.out.println(String.format("%.2f",b));
- }
Advertisement
Add Comment
Please, Sign In to add comment