Recap - True or False
Part of the Fundamentals section of Coddy's Kotlin journey. Lesson 40 of 93.
Challenge
EasyRead two integers and one string as input, then determine if a person can enter a venue.
You will receive three inputs:
- First input: the person's age (as a string, convert to Int)
- Second input: the minimum required age (as a string, convert to Int)
- Third input: whether they have a ticket - either
"true"or"false"(convert to Boolean)
A person can enter if their age is greater than or equal to the minimum age AND they have a ticket.
Print the result in this exact format:
Can enter: [result]Where [result] is true or false based on the conditions.
Try it yourself
fun main() {
// Read inputs
val ageInput = readLine()!!
val minAgeInput = readLine()!!
val hasTicketInput = readLine()!!
// TODO: Write your code below
// 1. Convert ageInput and minAgeInput to Int
// 2. Convert hasTicketInput to Boolean
// 3. Determine if the person can enter (age >= minAge AND has ticket)
// Output the result in the format: Can enter: [result]
println("Can enter: $canEnter")
}All lessons in Fundamentals
4Operators Part 1
Arithmetic OperatorsModulo OperatorAugmented AssignmentComparison OperatorsRecap - Simple Math7Basic IO
Println FunctionString TemplatesReadLine InputType ConversionRecap - Years Until RetirementRecap - True or False10Functions
Declare A FunctionParameters And ArgumentsReturn ValuesNamed ArgumentsDefault ValuesSingle Expression FunctionsRecap - Sigma FunctionRecap - Validation Function2Variables
Val vs VarType InferenceNumbersStringBooleanNaming ConventionsRecap - Initialize Variables5Operators Part 2
Logical Operators Part 1Logical Operators Part 2Logical Operators Part 3Ternary With If ExpressionRecap - Simple Logic8Bill Split Calculator
Welcome MessageGetting Input3Nullability
What Is Null SafetyNullable TypesSafe Call OperatorElvis OperatorFunction Challenge BasicsNot Null AssertionRecap - Safe Access6Decision Making
If StatementIf - ElseIf As An ExpressionWhen ExpressionWhen With RangesRecap - Simple Calculator9Loops
For LoopWhile LoopDo-While LoopBreakContinueRanges In LoopsNested LoopRecap - FactorialRecap - Dynamic InputPractice on your own: Kotlin playground