View Code of Problem 72


import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner=new Scanner(System.in);
		double M=scanner.nextDouble();
		int N=scanner.nextInt();
		double sum=0;
		double temp=M;
		for (int i = 0; i < N; i++) {
			sum=sum+temp;
			temp=temp/2;
			sum=sum+temp;
		}
		System.out.printf("%.2f %.2f", temp,sum-temp);
	}
}

Double click to view unformatted code.


Back to problem 72