Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

import java.util.Scanner;
import java.util.Arrays;
public class FirstAndLast
{
public static void main(String[] args)
{
Scanner in = new Scanner(System.in);
final int LENGTH =100;
double[] prices = new double[LENGTH];
System.out.println("Enter prices, Q to finish:");
int numberOfPrices =0;
while (in.hasNextDouble())
{
double price = in.nextDouble();
if (numberOfPrices < LENGTH)
{
prices[numberOfPrices]= price;
numberOfPrices++;
}
}
double sum =/* Your code goes here */;
System.out.printf("Sum of first and last: %.2f%n", sum);
}
}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Focus On Geodatabases In ArcGIS Pro

Authors: David W. Allen

1st Edition

1589484452, 978-1589484450

Students also viewed these Databases questions