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
Dillon logs online and receives this invitation to his best friend's birthday party:
Dominik [7]
Im goin to say that the red flags are gonna be instead of saying sams house add the address and for details they need to know if they need to bring anything for a just in case type deal. What games will be played? what time does it start? when does it end?<span />
7 0
3 years ago
Why does my computer download slower than my internet speed
Marina86 [1]

Answer:

because your computer has tabs opened

Explanation:

3 0
2 years ago
A file has a name and an
3241004551 [841]

Answer:

extension

Explanation:

3 0
2 years ago
What device is required to connect to the Internet?<br>O Wi-Fi<br>O an ISP<br>a router<br>a modem​
Mars2501 [29]

Answer:

modem

Explanation:

The primary piece of hardware you need is a modem. The type of Internet access you choose will determine the type of modem you need. Dial-up access uses a telephone modem, DSL service uses a DSL modem, cable access uses a cable modem, and satellite service uses a satellite adapter.

5 0
2 years ago
The multi-view drawing details an aluminum part and shows dimensions in centimeters. A rubber coating will be applied to the out
bija089 [108]
The answer is C I believe
8 0
3 years ago
Other questions:
  • For a project called "The Sheep Market", Aaron Koblin collected drawings of sheep from strangers on the Internet. He posted the
    14·1 answer
  • Can you structure this code in if-statements?
    15·1 answer
  • Full form of SMPT???
    15·1 answer
  • a corporation needs an operating system that allows the various teams in its office to network &amp; collaborate on projects. wh
    11·2 answers
  • Which option is used to apply formatting to multiple objects on a single slide while still maintaining the ability to manage the
    14·2 answers
  • Write c++ program bmi.cpp that asks the user bmi.cpp the weight (in kilograms) and height (in meters).
    12·1 answer
  • Draw the hierarchy chart and then plan the logic for a program that calculates a person’s body mass index (BMI).
    11·1 answer
  • Help me or I'll go insane I've 6x already I'm about to lose it!!!!
    11·2 answers
  • Which type of app is the best choice when it is critical to be able to use the device's features but performance is not critical
    5·1 answer
  • How does a security information and event management system (SIEM) in a SOC help the personnel fight against security threats
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!