Last active
February 9, 2017 12:40
-
-
Save cbilson/24be28b27a9adcb5be75c97e91461d23 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.File; | |
import java.io.FileNotFoundException; | |
import java.text.DecimalFormat; | |
import java.text.NumberFormat; | |
import java.util.Scanner; | |
public class DroidExpenses { | |
public static void main(String[] args) throws FileNotFoundException { | |
//Scanner scanner = new Scanner(System.in); | |
Scanner scanner = new Scanner(new File("C:\\Users\\cbilson\\DroidExpenses.txt")); | |
double blastRiflePrice = 350.34; | |
double visualSensorPrice = 230.90; | |
double auditorySensorPrice = 190.55; | |
double armPrice = 125.30; | |
double legPrice = 180.90; | |
NumberFormat formatter = new DecimalFormat("#.00"); | |
int problems = scanner.nextInt(); | |
for (int i = 0; i < problems; i++) { | |
double cost = 0.0; | |
cost += scanner.nextInt() * blastRiflePrice; | |
cost += scanner.nextInt() * visualSensorPrice; | |
cost += scanner.nextInt() * auditorySensorPrice; | |
cost += scanner.nextInt() * armPrice; | |
cost += scanner.nextInt() * legPrice; | |
System.out.println("$" + formatter.format(cost)); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment