Skip to content
Sign upLog in
← Back to Community
Need help with writing booleans in java
Profile icon
MadisonLouton

so I'm writing code this is the prompt:

Write a short quiz program that asks three true/false questions and stores the user's answers as booleans. At the end of the program, it should print the user's answers with the correct answers.

Note: you should use the same quiz questions and correct answers as the sample run below.

Sample run:

Java is a programming language, true or false?
true
Only numbers can be stored by variables in Java, true or false?
true
There are only 2 possible values that can be held by a boolean variable, true or false?
false
Question 1 - Your answer: true. Correct answer: true
Question 2 - Your answer: true. Correct answer: false
Question 3 - Your answer: false. Correct answer: true

the only code I have is listed below and i'm not sure if is right either. I'm just confused please help. Thanks.

/* Lesson 3 Coding Activity Question 3 */

import java.util.Scanner;

public class U1_L3_Activity_Three{
public static void main(String[] args){

Scanner scan = new Scanner(System.in); String t; String f; System.out.println("Java is a programming language, true or false?"); t = scan.nextLine(); System.out.println("Only numbers can be stored by variables in Java, true or false?"); f = scan.nextLine();

}

}

Answered by SixBeeps [earned 5 cycles]
View Answer
Voters
Profile icon
MadisonLouton
Comments
hotnewtop
Profile icon
SixBeeps

Instead of nextLine(), use nextBoolean(). That and make t and f into boolean variables.

Profile icon
PattanAhmed

@MadisonLouton
Hi,
On line 5 of your code,
Instead of this:-

t = scan.nextLine();

Turn into this:-

t = scan.nextBoolean();

This will automatically make t and f into boolean variables in the later use.

That's it.
Thanks!

Hope this helps

Profile icon
frederickgragg

Short for Business Process Management it is a term that describes activities and (or) events which are performed to optimize a business process. These activities are aided by software tools. The set ypes of software tools are also called BPM tools.

Most companies collect a large amount of data from their business operations.

To keep track of that information, a business and would need to use a wide range of software programs, such as Excel, Access and different data base applications for various departments through out their organization. Using multiple software programs makes it difficult to retrieve information in a timely manner and to perform an analysis of the data.

Related Exam:

https://www.linkedin.com/pulse/real-sap-certified-application-associate-cc4h41021-dumps-sam-reid/?published=t

https://community.wongcw.com/blogs/147675/Pass-Microsoft-SC-300-Exam-Questions-In-First-Attempt

https://colab.research.google.com/drive/1FDzIRSnC5mJ3Zt0JWvsOornBHcd2FqyM#scrollTo=4wLHi_KTTB8h

https://www.bitsdujour.com/profiles/ZlEHDE

https://graphcommons.com/certsboard

https://foro.zendalibros.com/forums/users/examstrust/

https://cirandas.net/dumpscollection/blog/prominent-c-ibp-2205-pdf-dumps-2022-free-pdf-download-c-ibp-2205-exam-dumps

The term Business Intelligence (BI) represents the tools and systems that play a key role in the strategic planning process of the corporation. These systems allow a company to gather, store, access and analyze corporate data to aid in decision-making. Generally these systems will illustrate business intelligence in the areas of customer profiling, customer support, market research, market segmentation, product profitability, statistical analysis, and inventory and distribution analysis to name a few.

Profile icon
JeyAbrams

exceptionally intriguing to peruse, much obliged! I need to share one of the most mind-blowing web-based administrations for purchasing and composing papers as I would see it - Programminghomework.help. These folks are genuine expert authors who can manage any theme on time without literary theft and utilizing genuine sources.

Profile icon
Mateerleen

People often meet issues with any type of writing. As for me, I never liked academic writing, and I often have to ask for help. Last month I needed a nurse writer, and I found an excellent one who helped me with my paper. I was impressed with the quality, and the price was affordable.

Profile icon
JackyApril

Why do you need to read essay service reviews? Well, we need to read what others think about the writer and their writing. This will give us insight into the writer's personality. This will answer questions about whether a writer can write a well-written resume that your teacher will love. It is for this reason that I always read WritngJudge - https://www.writingjudge.com/ reviews and choose the best writing services.

Profile icon
JeyAbrams

@JackyApril
Hi, it is incredible day for you all. I got truly usefull tip for study, pay someone to do my nursing assignment, assuming you want assistance with any sorts of desk work, you can undoubtedly go to this expert scholars.

Profile icon
MadisonLouton

Thank you so much!

Profile icon
PattanAhmed

@MadisonLouton
Welcome!
Happy to help you.

Please mark my answer if my post helps
Thanks!