this is my java code.. plz feel free to make any changes ...
Im new to this kind of programming so i will be thankful for any help i can get
package Project;
import java.io.*;
public class Question3 {
private static String amount;
public static String total;
String names=null;
/**
* @param args the command line arguments
* @throws java.lang.Exception
*/
public static void main(String[] args) throws Exception {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String names [];//This is the declaration
names = new String[5];//Create an array
//While loop
int x=0;
while(true){
System.out.println("Please enter client name");
names [x] = br.readLine();
//enter rate
System.out.println("Please enter rate");
float rate= Float.parseFloat(br.readLine());
System.out.println("Please enter rental");
//rental
float rental = Float.parseFloat(br.readLine());
//Prev meter reading
System.out.println("Please enter previous meter reading: ");
float prevMeter = Float.parseFloat(br.readLine());
//Present meter reading
System.out.println("Please enter present meter reading: ");
float presMeter= Float.parseFloat(br.readLine());
//Unit used
float unitUsed =prevMeter-presMeter;
//calculation of total amount
float totalX = rental+(unitUsed*rate);
System.out.println("$"+totalX+" is the amount due for "+names[x]);
//ask to enter another
String data;
System.out.println("Would like to enter another client ");
data = br.readLine();
if(data.equals("no")){
break;
}//close if statement
x++;
}//end while loop
//for loop
for(int k=0; k<2; k++){
System.out.println(totalX +" is the total amount for "+ names[x]);
}
}
}
--- Update ---
I just want it to print like this for example :
This is the amount for jack (amount of cash).
This is the amount for jane (amount of cash)