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
Java: which expression is evaluated first
nignag [31]

Answer:c ll d  

Explanation:

cus they are inside ()--parantheses

5 0
3 years ago
Using a personal computer to produce high quality printed documents
alisha [4.7K]

Answer:

Desktop publishing

6 0
4 years ago
Which of the following is an example of tangible property?
lyudmila [28]
<span>B an idea for an invention that your dad mentioned briefly but did not write down</span>
8 0
3 years ago
If a friend changes the password on your phone how do you get into it if you dont know the password
kotegsom [21]
Ask your friend to tell you the password
3 0
3 years ago
Which of these definitions BEST explains what plagiarism is:
Alex777 [14]
To use another person's work without crediting the source.
6 0
3 years ago
Read 2 more answers
Other questions:
  • Can you know what time someone retweeted
    5·1 answer
  • Which of the below statements describes the nature of HTML elements - check as many as apply
    6·1 answer
  • Which cloud computing service model will enable an application developer to develop, manage, and test their applications without
    15·1 answer
  • What video game has made the most money as of 2016?
    15·2 answers
  • Which of the following is the core of an operating system that maintains the computer’s clock, starts applications, and assigns
    5·1 answer
  • A cache has been designed such that it has 512 lines, with each line or block containing 8 words. Identify the line number, tag,
    7·1 answer
  • What is not true of credit scores?
    11·1 answer
  • I need a good science fair name I’m doing a homemade water filter and I have no idea what the title should be plz help
    14·1 answer
  • A photographer stores digital photographs on her computer. In this case the photographs are considered the data. Each photograph
    6·1 answer
  • Do you guys answer questions about cyber security?
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!