Currently I am just starting out with java and need some help with the basics. I would like to make the program to be universal and for the user to input the price of the books, instead of it being written in the code. I have looked up and tried on my own but I just keep falling over and over again so if you anyone could explain it in lame terms it would be appreciated.
package com.test1;
public class example1
{
public static void printTotalAmountForBooks(double[] prices)
{
double totalAmount = 0;
for (double singleBookPrice : prices)
{
totalAmount += singleBookPrice;
}
System.out.println("The total amount of all books is: " + totalAmount);
}
public static void main(String[] args)
{
double [] pricesArr;
pricesArr = new double[] { 15.93, 12.45, 22.54, 14.56, 23.21 };
printTotalAmountForBooks(pricesArr);
}
}