Write a program to find time using battery capacity and changing current value


Program
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); System.out.println("Enter battery capacity:"); double capacity = sc.nextDouble(); if(!(capacity>=1000 && capacity<=10000)) { System.out.println("Invalid battery capacity"); return; } System.out.println("Enter charging current value:"); double current = sc.nextDouble(); if(!(current>=300 && current<=2100)) { System.out.println("Invalid output current"); return; } double time=0.0f; time = (capacity/current)*1.2; System.out.println(String.format("%.2f",time)+" Hours"); } }
Input
Output