1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Paha777 [63]
3 years ago
14

write a java program to accept three item names and prices, and output them. Also output the average price if one of the items i

s named Peas (not case sensitive) otherwise output: no average output".
Computers and Technology
1 answer:
N76 [4]3 years ago
8 0

Answer:

// program in java.

// package

import java.util.*;

// class definition

class Main

{

// main method of the class

public static void main (String[] args) throws java.lang.Exception

{

   try{

    // scanner object to read input

Scanner scr=new Scanner(System.in);

 // string array

String name[] = new String[3];

 // price array

      double price[] = new double[3];

      // variable

      double sum = 0,avg;

      boolean flag = false;

      // read three name and their price

      for(int i=0;i<3;i++)

      {

          System.out.print("Enter item "+(i+1)+" name:");

          name[i]=scr.next();

          System.out.print("Enter item "+(i+1)+" price:");

          price[i]=scr.nextDouble();

          sum=sum+price[i];

          // if any name is "peas"

          if(name[i].equalsIgnoreCase("peas"))

          flag = true;

      }

System.out.println("Name and their price:");

      for(int i=0;i<3;i++)

      {

          System.out.println(name[i]+":"+price[i]);

         

      }

      // if flag is true

      if(flag)

      {

      // calculate average

          avg=sum/3;

          // print average

          System.out.println("Average price is:"+avg);

      }

      else

      System.out.println("no average output");

   

   }catch(Exception ex){

       return;}

}

}

Explanation:

Read three name and their price from user.If any name is equal to "peas" without case sensitive then find the average of three price and print the average.If their is no name equal to "peas" then print "no average output".

Output:

Enter item 1 name:apple                                                                                                    

Enter item 1 price:20                                                                                                      

Enter item 2 name:kiwi                                                                                                    

Enter item 2 price:15                                                                                                      

Enter item 3 name:banana                                                                                                  

Enter item 3 price:20    

Name and their price:

apple:20

kiwi:15

banana:20                                                                                            

no average output

You might be interested in
5. How is shutter speed generally measured? What do the measurements mean?
Leokris [45]
Shutter speed<span> is </span>generally measured<span> by the scientific symbol “s”. The </span>measurement means<span> that the </span>measurements<span> in "s" is the reciprocal of the number when the denominator is put on the numerator side instead. ... Aperture is </span>measured<span> by f's.</span>
6 0
3 years ago
Read 2 more answers
When you see a blank pointer this means you can drag the row or column border to change height or width
Orlov [11]
No, you would see arrows pointing in opposite directions <--> like so
7 0
3 years ago
Write two separate formulas using different commands that concatenate " john and "smith" together to form " John Smith"
VladimirAG [237]

Answer:

1. =CONCATENATE(" John"," ","Smith")

2. =(" John"&" "&"Smith")

Explanation:

Given

Two separate strings; "John" and "Smith"

Required

2 separate formulas to concatenate both strings to form " John Smith"

There are several ways to concatenate strings in Microsoft Office Excel; one of the methods is using the concatenate function while the another method is using the traditional & operator.

Using the concatenate function, the formula is as follows

=CONCATENATE(" John"," ","Smith")

This function will combine the " John", " " and "Smith" to give a new string " John Smith" (without the quotes).

Using the traditional & operator may be a little bit difficult (and not frequently used) but the formula is as follows;

=(" John"&" "&"Smith")

The result will be the same as (1) above

5 0
3 years ago
PLS HELP SOON AS POSSIBLE WILL GIVE BRAINLIEST!!!
Evgesh-ka [11]

The best reason that the title of an article published on a website might not help to determine if the information is reliable is that titles attract readers; they do not guarantee accuracy

  • The title of an article tells the reader what the work or article is all about. It summarizes the whole work into a single text. Website in bid to attract more people to their page most times uses attractive titles or commonly search words but this does not show that the work is accurate.

  • People often make or select a title that grabs attention and one that makes people want to read further

Conclusively we can say that The title of an article published on website is meant to attract readers as they do not guarantee accuracy

Learn more from

brainly.com/question/11427677

5 0
2 years ago
Suppose that the splits at every level of quicksort are in the proportion 1 − α to α where 0 &lt; α ≤ 1/2 is a constant. Show th
Lady_Fox [76]

Answer:

Explanation:

The minimum depth occurs for the path that always takes the smaller portion of the

split, i.e., the nodes that takes α proportion of work from the parent node. The first

node in the path(after the root) gets α proportion of the work(the size of data

processed by this node is αn), the second one get (2)

so on. The recursion bottoms

out when the size of data becomes 1. Assume the recursion ends at level h, we have

(ℎ) = 1

h = log 1/ = lg(1/)/ lg = − lg / lg

Maximum depth m is similar with minimum depth

(1 − )() = 1

m = log1− 1/ = lg(1/)/ lg(1 − ) = − lg / lg(1 − )

4 0
3 years ago
Other questions:
  • To use an outline for writing a formal business document what should you do after entering your bottom line statement
    10·1 answer
  • The operations planning practice of inputting sales forecasts into computer software that accurately predicts the amount and tim
    6·1 answer
  • What is f(-3) for the function f(a)=-2a2-5a+4?​
    10·1 answer
  • Write a program roman which converts numbers from decimal notation into Roman numerals. roman takes a single argument, a string
    10·1 answer
  • In the writing and language test of the SAT, questions ask students to do which of the following? A. Write an essay B. Define a
    14·2 answers
  • Each new term in the Fibonacci sequence is generated by adding the previous two terms. By starting with 1 and 2, the first 10 te
    13·1 answer
  • Which of the following is the file type of Microsoft® Publisher files?
    12·2 answers
  • You have a technical interview for a new position in digital media. One of the questions you are asked is this: “A client asks y
    13·1 answer
  • What is syllabus of diploma in computer after class 10​
    10·1 answer
  • You have been asked to replace a cracked screen on a laptop. The replacement screen was delivered today, but it did not include
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!