Question

David bought n apples. x percent of these apples are red. Using Java, calculate how many...

David bought n apples. x percent of these apples are red. Using Java, calculate how many apples are green. n and x are input from console

Homework Answers

Answer #1
//DavidApples.java
import java.util.Scanner;
public class DavidApples {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n;
        double x;

        System.out.print("Enter value for n: ");
        n = scan.nextInt();

        System.out.print("Enter value for x: ");
        x = scan.nextDouble();

        int green = (int) (n*(100-x)/100);

        System.out.println("Number of green apples: "+green);
    }
}

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
There are 4 balls in a bag: Red, Blue, Green and Yellow. In how many ways...
There are 4 balls in a bag: Red, Blue, Green and Yellow. In how many ways you can pick k balls from the urn of n with replacement?
how many ways are there to choose nineteen identical balls from a pile of red, yellow,...
how many ways are there to choose nineteen identical balls from a pile of red, yellow, blue, and green balls if there can be no more than seven balls of each color?
Using the formual (2n-3)! / [2^n-2 x (n-2)!], how many possible rooted trees can you generate...
Using the formual (2n-3)! / [2^n-2 x (n-2)!], how many possible rooted trees can you generate using 6 organisma?
Please show how to solve using EXCEL ONLY EXCEL INSTRUCTIONS ONLY 8. David Hoffman purchases a...
Please show how to solve using EXCEL ONLY EXCEL INSTRUCTIONS ONLY 8. David Hoffman purchases a $1,000 20‐year bond with an 8 percent coupon rate (annual payments). Yields on comparable bonds are 10 percent. David expects that, 2 years from now, yields on comparable bonds will have declined to 9 percent. Find his expected yield, assuming the bond is sold in 2 years.
using java LO: (Remember) Students will recall how to read from standard input. LO: (Apply) Students...
using java LO: (Remember) Students will recall how to read from standard input. LO: (Apply) Students will write loops that iterate as long as a condition is true. Write a program that reads words from standard input and displays them to standard output. When the word "end" is read, print it out and then stop reading input. starter code: import java.util.Scanner; /* * Reads and displays words from standard input until hitting a stop word. */ public class WhileLoop {...
Using the experimental sampling strategy, how many samples of size 4 (n = 4) can be...
Using the experimental sampling strategy, how many samples of size 4 (n = 4) can be drawn from the following population sizes? (a) N = 6 (b) N = 7 (c) N = 8 (d) N = 9
how do you calculate the percent of EBIT over many years? such as five or more...
how do you calculate the percent of EBIT over many years? such as five or more years as a percent.
How many eigenstates in the n=3 energy level for hydrogen atom? How can I calculate this?...
How many eigenstates in the n=3 energy level for hydrogen atom? How can I calculate this? Please explain your all step! Thank you!
is there anything wrong with the solution. the question are from java course Write a main...
is there anything wrong with the solution. the question are from java course Write a main method that will request the user to enter Strings using a JOptionPane input dialog. The method should continue accepting strings until the user types “STOP”.       Then, using a JOptionPane message dialog, tell the user how many of the strings begin and end with a digit. Answer: import javax.swing.*; public class IsAllLetters {     public static void main(String[] args) {         String input;         int count =...
Using the normal distribution, calculate the following probabilities: a) P(X≤16|n=50, p=0.70) b) P(10≤X≤16|n=50, p=0.50)
Using the normal distribution, calculate the following probabilities: a) P(X≤16|n=50, p=0.70) b) P(10≤X≤16|n=50, p=0.50)
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT