1. Member Join Date
Oct 2013
Posts
1
Rep Power
0

## gas station project

import java.util.Scanner;

class station{
public static void main(String[] args) {

Scanner writer = new Scanner(System.in);
double[] prices;
String[] stations;
prices = new double;
stations = new String;

System.out.println("What is the price per gallon of Shell?");
prices = writer.nextInt();
System.out.println("What is the price per gallon of BP?");
prices = writer.nextInt();
System.out.println("What is the price per gallon of Speedway?");
prices = writer.nextInt();
System.out.println("What is the price per gallon of Marathon?");
prices= writer.nextInt();

stations = "Shell";
stations = "BP";
stations = "Speedway";
stations = "Marathon";

}

public static void calculations(int[] prices, String[] stations) {
int times = 0;
double fuel = 25;
double tax = .93;
double[] total;
total = new double;
while (times < 4) {
total[times] = (prices[times] * fuel) * tax;
System.out.println("The price of " + stations[times] + " is " + total[times]);
times = times + 1;
}
}
}

The project is to have an array be populated with four gas stations. A user is then prompted to enter the price per a gallon for each station and have the values entered into an array. Then with 25 gallons being assumed as the amount bought, we are to create a void method that will output the total cost of gas for each gas station with a 7% sales tax included.

1) Did I do this correctly?
2) Why am I not receiving an output stating the prices for the stations?  Reply With Quote

2. ## Re: gas station project

If you are not getting the correct output that answers your first question.
When does your code call the calculations method? It doesn't happen by magic.  Reply With Quote

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•