/*
Tijana Romcevic
Java 111A
This code is asking user for the list of ithems and prices for each of them that it puts on shopinglist,
and calculates the total amounth of money that would be spent.
*/

import java.util.Scanner;
class ShopingList
{
	public static void main (String[] args)
	{
		Scanner s = new Scanner(System.in);

		int sizeOfList;
		String[] whichItems;
		double[] prices; 
		sizeOfList = numberItems();
		whichItems = getItems(sizeOfList);
		prices = getPrices(whichItems);
	    printTotal(prices);		
		
	}

/*
This method does not accept any arguments, it askes user for the number of items on the list and returns that number.
*/
	public static int numberItems()
	{
		Scanner scan = new Scanner(System.in);
		int size;

		System.out.println("How many items do you want on your list?");
		size = scan.nextInt();
		

		return size;
	}
/*
This method accepts one argumrnt, uses the loop to return each item name to the main.
*/

	public static String[] getItems(int length)
	{
		Scanner sc = new Scanner(System.in);
		String[] itemsNames = new String[length];

		System.out.println("Which items do you want on your list? After each ithem press return.");
		
		for(int i = 0; i < length; i++)
		{
			itemsNames[i] = sc.nextLine();
		}		

		return itemsNames;
	}
/*
This method accepts list of iems and returns its prices
*/
	public static double[] getPrices(String[] items)
	{
		Scanner scann = new Scanner(System.in);
		double[] itemsPrice = new double[items.length];

		System.out.println(" Please enter the price for each item:");

		for(int i = 0; i < items.length; i++)
		{
			itemsPrice[i] = scann.nextDouble();
			//System.out.printf(" %.2f \n" ,itemsPrice[i] );

		}

		return itemsPrice;

	}
/*
This meod prints the total amount of prices
*/
	public static void printTotal(double[] allPrices)
	{
		double total = 0; 
		for (int i = 0; i < allPrices.length; i++)
		{ 
		total = allPrices[i] + total; 
		}
		System.out.printf("Total price of your shoping list items is %.2f \n " , total );

	} 
}

/* Output 
Telemachuss-Air:homeworks Telemachus$ java ShopingList
How many items do you want on your list?
6
Which items do you want on your list? After each ithem press return.
a
s
d
f
gh
h
 Please enter the price for each item:
1.11
2.22
3.33
4.44
5.55
6.66
Total price of your shoping list items is 23.31 
Telemachuss-Air:homeworks Telemachus$ 
*/


syntax highlighted by Code2HTML, v. 0.9