Question

import java.util.Scanner; public class EggBasket2 { public static void main (String [] args) { int numberOfBaskets,...

import java.util.Scanner;
public class EggBasket2
{
    public static void main (String [] args)
    {
        int numberOfBaskets, eggsPerBasket, totalEggs;
        Scanner keyboard = new Scanner (System.in);
        System.out.println ("Enter the number of eggs in each basket:");
        eggsPerBasket = keyboard.nextInt ();
        System.out.println ("Enter the number of baskets:");
        numberOfBaskets = keyboard.nextInt ();
        totalEggs = numberOfBaskets * eggsPerBasket;
        System.out.println ("If you have");
        System.out.println (eggsPerBasket + " eggs per basket and");
        System.out.println (numberOfBaskets + " baskets, then");
        System.out.println ("the total number of eggs is " + totalEggs);
        System.out.println ("Now we take two eggs out of each basket.");
        eggsPerBasket = eggsPerBasket - 2;
        totalEggs = numberOfBaskets * eggsPerBasket;
        System.out.println ("You now have");
        System.out.println (eggsPerBasket + " eggs per basket and");
        System.out.println (numberOfBaskets + " baskets.");
        System.out.println ("The new total number of eggs is " + totalEggs);
    }
}

1.) Take the following java code and modify it answering the following questions.

How much money you want to deposit a year  
How many years
What is the expected rate of return with a 10% INTEREST RATE
0 0
Add a comment Improve this question Transcribed image text
Answer #1

import java.util.Scanner;
public class DepositReturn
{
public static void main (String [] args)
{
double deposit_money, years, return_amount;
Scanner keyboard = new Scanner (System.in);
System.out.println ("How much money you want to deposit a year:");
deposit_money = keyboard.nextDouble ();
System.out.println ("How many years:");
years = keyboard.nextDouble ();
return_amount=deposit_money*years + years* deposit_money*0.1;;
  
System.out.println ("If you have");
System.out.println (deposit_money + " deposited per year");
System.out.println (years + " years, then");
System.out.println ("the total return amount is " + return_amount);
System.out.println ("Now we take 100$ from deposited money of each year.");
deposit_money = deposit_money-100;
return_amount = deposit_money*years + years* deposit_money*0.1;
System.out.println ("You now have");
System.out.println (deposit_money + "deposited each year and for");
System.out.println (years + " years.");
System.out.println ("The new total return amount is " + return_amount);
}
}

/***********************************************************************************/

output:

for input:STDIN

500

10

OUTPUT

$javac DepositReturn.java
$java -Xmx128M -Xms16M DepositReturn
How much money you want to deposit a year:
How many years:
If you have
500.0 deposited per year
10.0 years, then
the total return amount is 5500.0
Now we take 100$ from deposited money of each year.
You now have
400.0deposited each year and for
10.0 years.
The new total return amount is 4400.0

For any clarifications , please post in comment section. Thank you

Add a comment
Know the answer?
Add Answer to:
import java.util.Scanner; public class EggBasket2 { public static void main (String [] args) { int numberOfBaskets,...
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. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • import java.util.Scanner; public class TriangleMaker {    public static void main(String[] args) {        //...

    import java.util.Scanner; public class TriangleMaker {    public static void main(String[] args) {        // TODO Auto-generated method stub        System.out.println("Welcome to the Triangle Maker! Enter the size of the triangle.");        Scanner keyboard = new Scanner(System.in);    int size = keyboard.nextInt();    for (int i = 1; i <= size; i++)    {    for (int j = 0; j < i; j++)    {    System.out.print("*");    }    System.out.println();    }    for (int...

  • make this program run import java.util.Scanner; public class PetDemo { public static void main (String []...

    make this program run import java.util.Scanner; public class PetDemo { public static void main (String [] args) { Pet yourPet = new Pet ("Jane Doe"); System.out.println ("My records on your pet are inaccurate."); System.out.println ("Here is what they currently say:"); yourPet.writeOutput (); Scanner keyboard = new Scanner (System.in); System.out.println ("Please enter the correct pet name:"); String correctName = keyboard.nextLine (); yourPet.setName (correctName); System.out.println ("Please enter the correct pet age:"); int correctAge = keyboard.nextInt (); yourPet.setAge (correctAge); System.out.println ("Please enter the...

  • import java.util.Scanner; public class SCAN { public static void main(String[ ] args) { int x, y,...

    import java.util.Scanner; public class SCAN { public static void main(String[ ] args) { int x, y, z; double average; Scanner scan = new Scanner(System.in); System.out.println("Enter an integer value"); x = scan.nextInt( ); System.out.println("Enter another integer value"); y = scan.nextInt( ); System.out.println("Enter a third integer value"); z = scan.nextInt( ); average = (x + y + z) / 3; System.out.println("The result of my calculation is " + average); } } What is output if x = 0, y = 1 and...

  • import java.util.Scanner; public class SieveOfEratosthenes {    public static void main(String args[]) {       Scanner sc...

    import java.util.Scanner; public class SieveOfEratosthenes {    public static void main(String args[]) {       Scanner sc = new Scanner(System.in);       System.out.println("Enter a number");       int num = sc.nextInt();       boolean[] bool = new boolean[num];            for (int i = 0; i< bool.length; i++) {          bool[i] = true;       }       for (int i = 2; i< Math.sqrt(num); i++) {          if(bool[i] == true) {             for(int j = (i*i); j<num; j = j+i) {                bool[j] = false;...

  • import java.util.Scanner; import java.util.ArrayList; public class P3A2_BRANDT_4005916 {    public static void main(String[] args)    {...

    import java.util.Scanner; import java.util.ArrayList; public class P3A2_BRANDT_4005916 {    public static void main(String[] args)    {        String name;        String answer;        int correct = 0;        int incorrect = 0;        Scanner phantom = new Scanner(System.in);        System.out.println("Hello, What is your name?");        name = phantom.nextLine();        System.out.println("Welcome " + name + "!\n");        System.out.println("My name is Danielle Brandt. "            +"This is a quiz program that...

  • Consider the following sample program: import java.util.Scanner; public class Palindrome { public static void main(String[] args){...

    Consider the following sample program: import java.util.Scanner; public class Palindrome { public static void main(String[] args){ Scanner kb = new Scanner(System.in); System.out.println("Enter a word:"); String word = kb.next();    String reverse = ""; for (int i=word.length()-1; i>=0; i--) reverse += word.charAt(i); boolean result = reverse.equalsIgnoreCase(word);    if (result) System.out.println("The word " +word+ " is a Palindrome."); else System.out.println("The word " +word+ " is not a Palindrome."); } } Rewrite the program so that the main method is: public static void...

  • import java.util.Scanner; public class Client{ public static void main(String args[]){    Coin quarter = new Coin(25);...

    import java.util.Scanner; public class Client{ public static void main(String args[]){    Coin quarter = new Coin(25); Coin dime = new Coin(10); Coin nickel = new Coin(5);    Scanner keyboard = new Scanner(System.in);    int i = 0; int total = 0;    while(true){    i++; System.out.println("Round " + i + ": "); quarter.toss(); System.out.println("Quarter is " + quarter.getSideUp()); if(quarter.getSideUp() == "HEADS") total = total + quarter.getValue();    dime.toss(); System.out.println("Dime is " + dime.getSideUp()); if(dime.getSideUp() == "HEADS") total = total +...

  • import java.util.Scanner; public class TempConvert { public static void main(String[] args) { Scanner scnr = new...

    import java.util.Scanner; public class TempConvert { public static void main(String[] args) { Scanner scnr = new Scanner(System.in); //ask the user for a temperature System.out.println("Enter a temperature:"); double temp = scnr.nextDouble(); //ask the user for the scale of the temperature System.out.println("Is that Fahrenheit (F) or Celsius (C)?"); char choice = scnr.next().charAt(0); if(choice == 'F') { //convert to Celsius if given temperature was Fahrenheit System.out.println(temp + " degrees Fahrenheit is " + ((5.0/9) * (temp-32)) + " degrees Celsius"); } else {...

  • import java.util.Scanner; public class Chpt7_Project {    public static void bubbleSort(int[] list)    {    int...

    import java.util.Scanner; public class Chpt7_Project {    public static void bubbleSort(int[] list)    {    int temp;                       for (int i = list.length - 1; i > 0; i--)    {    for (int j = 0; j < i; j++)    {    if (list[j] > list[j + 1])    {    temp = list[j];    list[j] = list[j + 1];    list[j + 1] = temp;    }    }    }   ...

  • import java.util.Scanner; public class creditScore { public static void main(String[]args) { // declare and initialize variables...

    import java.util.Scanner; public class creditScore { public static void main(String[]args) { // declare and initialize variables int creditScore; double loanAmount,interestRate,interestAmount; final double I_a = 5.56,I_b = 6.38,I_c = 7.12,I_d = 9.34,I_e = 12.45,I_f = 0; String instructions = "This program calculates annual interest\n"+"based on a credit score.\n\n"; String output; Scanner input = new Scanner(System.in);// for receiving input from keyboard // get input from user System.out.println(instructions ); System.out.println("Enter the loan amount: $"); loanAmount = input.nextDouble(); System.out.println("Enter the credit score: "); creditScore...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT