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
GrogVix [38]
3 years ago
12

"Using the printf method, print the values of the integer variables bottles and cans so that the output looks like this: Bottles

: 8 Cans: 24 The numbers to the right should line up. (You may assume that the numbers have at most 8 digits.)"
Computers and Technology
1 answer:
Anika [276]3 years ago
6 0

Answer:

import java.util.Scanner;

public class Main

{

public static void main(String[] args) {

       Scanner in = new Scanner(System.in);

       

       System.out.println("Enter the number of bottles and cans:");

       int numberOfbottles = in.nextInt();

       int numberOfcans = in.nextInt();

       System.out.printf("Bottles: %8d\n", numberOfbottles);

       System.out.printf("Cans:    %8d\n", numberOfcans);

}

}

Explanation:

Ask user to input the number of bottles and cans using Scanner class

Print the results so that the numbers to the right line up (Since we know that the numbers have at most 8 digits, we can use %8d in printf. Also, be aware that how printf statements are written so that the numbers line up)

You might be interested in
What is the name of an instruction that interrupts a program being executed and requests a service from the operating system
tresset_1 [31]
“Interrupt” is what I think the answer is
7 0
2 years ago
Difference between website and web server
Volgvan

Answer:

a web server is a computer than runs websites

7 0
3 years ago
Read 2 more answers
Which sql server 2012 edition is targeted at hosted, internet-facing deployment?
Mice21 [21]
<span>The Web version will work for this type of need. This version runs at a slightly lesser capability than the full version, but will still perform many of the advanced functions of SQL Server. The processor and RAM utilizations are a bit less than the maximum provided in other versions.</span>
7 0
3 years ago
How many feet do you have to stop away from a school bus
mr_godi [17]
You are required by law to stop twenty feet away from a school bus when driving.
7 0
3 years ago
When you pass an array name as an argument to the function what is actually being passed
Allushta [10]

Answer:

The Base address of the array is being passed

6 0
3 years ago
Other questions:
  • Skylar is viewing her personal and business calendar in a side-by-side fashion, but she would like to view a single calendar tha
    6·1 answer
  • Using Module operator, write a java program to print odd number between 0 and 1000​
    5·1 answer
  • Janet is testing the effectiveness of four different plant foods. She plants four identical seeds in four identical pots, supply
    6·2 answers
  • What is the formula for calculating the average of cells<br> C2 through C30?
    15·1 answer
  • Bit rate is a measure of how many bits of data are transmitted per second. Compared to videos with a higher bit rate, the same v
    13·1 answer
  • Create a base class named rectangle that contains lenght and width data members.
    9·1 answer
  • Diane is receiving a lot of unwanted e-mail. What steps can she take to reduce the amount of e-mail she receives?
    12·1 answer
  • Complete the following table.
    6·1 answer
  • What role do play in medicine ​
    11·1 answer
  • Kim is writing a sql query that will pull a list of customers with outstanding orders and the sales rep for each order. What sho
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!