-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4adbe2e
commit 99878d9
Showing
2 changed files
with
27 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,27 @@ | ||
struct userAccount{ | ||
var userName:String | ||
var userAge:Int | ||
var isActive : Bool | ||
|
||
func printUserDetails(){print("\(userName) is \(userAge) years old") | ||
if(isActive==true){ | ||
struct userAccount { | ||
var userName: String | ||
var userAge: Int | ||
var isActive: Bool | ||
|
||
func printUserDetails() { | ||
print("\(userName) is \(userAge) years old") | ||
if isActive == true { | ||
print("Account is active") | ||
} | ||
else { | ||
} else { | ||
print("Account is inactive") | ||
} | ||
} | ||
|
||
func calculateDiscount()->Double{ | ||
var discount:Double = 0.0 | ||
if userAge>60{discount=0.2} | ||
else if(userAge>30){ | ||
|
||
func calculateDiscount() -> Double { | ||
var discount: Double = 0.0 | ||
if userAge > 60 { | ||
discount = 0.2 | ||
} else if userAge > 30 { | ||
discount = 0.1 | ||
} | ||
return discount | ||
} | ||
return discount | ||
}} | ||
} | ||
|
||
let newUser=userAccount(userName: "john",userAge:25,isActive:true) | ||
let newUser = userAccount(userName: "john", userAge: 25, isActive: true) | ||
newUser.printUserDetails() |