-
Notifications
You must be signed in to change notification settings - Fork 13
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
hamed
committed
Jun 30, 2022
1 parent
d80d9f6
commit 4430901
Showing
7 changed files
with
228 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package main | ||
|
||
import "fmt" | ||
|
||
func main() { | ||
|
||
var salary float64 | ||
var minSalary float64 = 5_600_000 | ||
var taxPercent float64 = 0 | ||
var knowledgeBase bool = true | ||
|
||
fmt.Print("Enter your salary: ") | ||
fmt.Scanln(&salary) | ||
|
||
if salary <= minSalary { | ||
taxPercent = 0 | ||
} else if knowledgeBase || salary > minSalary && salary <= minSalary*2 { | ||
taxPercent = 0.05 | ||
} else if salary > minSalary*2 && salary <= minSalary*3 { | ||
taxPercent = 0.07 | ||
} else if salary > minSalary*3 && salary <= minSalary*4 { | ||
taxPercent = 0.10 | ||
} else { | ||
taxPercent = 0.15 | ||
} | ||
|
||
fmt.Printf("Your tax percent is: %.2f\n", taxPercent) | ||
fmt.Printf("Your tax is: %.2f\n", taxPercent*salary) | ||
|
||
fmt.Printf("Your salary is: %.2f\n", salary-taxPercent*salary) | ||
|
||
} |
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 |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package main | ||
|
||
import "fmt" | ||
|
||
func main() { | ||
var score float64 | ||
|
||
println("Enter your score: ") | ||
fmt.Scanln(&score) | ||
|
||
switch { | ||
case score >= 16 && score <= 20: | ||
println("A") | ||
case score >= 11 && score <= 15.99: | ||
println("B") | ||
case score >= 6 && score <= 10.99: | ||
println("C") | ||
case score >= 0 && score <= 5.99: | ||
println("D") | ||
default: | ||
println("Unknown") | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package main | ||
|
||
import "fmt" | ||
|
||
func main() { | ||
|
||
var num int | ||
var provinceName string | ||
|
||
println("Please enter num: ") | ||
|
||
fmt.Scanln(&num) | ||
|
||
switch num { | ||
case 72, 82, 92: | ||
provinceName = "Mazandaran" | ||
case 11, 22, 33, 44, 55, 66, 77, 88, 99, 10, 20, 30, 40, 50, 60, 70, 80, 90: | ||
provinceName = "Tehran" | ||
case 13, 23, 43, 53: | ||
provinceName = "Isfahan" | ||
case 47, 57, 67: | ||
provinceName = "Markazi" | ||
default: | ||
provinceName = "Unknown" | ||
} | ||
|
||
println(provinceName) | ||
} |
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 |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package main | ||
|
||
import "fmt" | ||
|
||
func main() { | ||
|
||
var salary float64 | ||
var minSalary float64 = 5_600_000 | ||
var taxPercent float64 = 0 | ||
|
||
fmt.Print("Enter your salary: ") | ||
fmt.Scanln(&salary) | ||
|
||
switch { | ||
case salary <= minSalary: | ||
taxPercent = 0 | ||
case salary > minSalary && salary <= minSalary*2: | ||
taxPercent = 0.05 | ||
case salary > minSalary*2 && salary <= minSalary*3: | ||
taxPercent = 0.07 | ||
case salary > minSalary*3 && salary <= minSalary*4: | ||
taxPercent = 0.10 | ||
default: | ||
taxPercent = 0.15 | ||
} | ||
|
||
fmt.Printf("Your tax percent is: %.2f\n", taxPercent) | ||
fmt.Printf("Your tax is: %.2f\n", taxPercent*salary) | ||
|
||
fmt.Printf("Your salary is: %.2f\n", salary-taxPercent*salary) | ||
|
||
} |
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 |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
) | ||
|
||
func main() { | ||
var score float64 | ||
|
||
println("Enter your score: ") | ||
fmt.Scanln(&score) | ||
|
||
switch { | ||
case score >= 16 && score <= 20: | ||
println("A") | ||
break | ||
case score >= 11 && score <= 15.99: | ||
println("B") | ||
case score >= 6 && score <= 10.99: | ||
println("C") | ||
case score >= 0 && score <= 5.99: | ||
println("D") | ||
default: | ||
println("Unknown") | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"strings" | ||
) | ||
|
||
func main() { | ||
|
||
var notificationType string // "sms,email,push" | ||
|
||
println("Enter notification type: ") | ||
|
||
fmt.Scanln(¬ificationType) | ||
|
||
switch { | ||
case strings.Contains(notificationType, "sms"): | ||
println("SMS sent") | ||
fallthrough | ||
case strings.Contains(notificationType, "email"): | ||
println("Email sent") | ||
fallthrough | ||
case strings.Contains(notificationType, "push"): | ||
println("Push sent") | ||
default: | ||
println("Unknown") | ||
} | ||
|
||
} |
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 |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package main | ||
|
||
import "fmt" | ||
|
||
const monthDays1 int = 31 | ||
const monthDays2 int = 30 | ||
const monthDays3 int = 29 | ||
|
||
func main() { | ||
|
||
var month int | ||
var totalDays int = 0 | ||
|
||
println("Please enter a month number: ") | ||
|
||
fmt.Scanln(&month) | ||
|
||
switch month { | ||
case 12: | ||
totalDays += monthDays3 | ||
fallthrough | ||
case 11: | ||
totalDays += monthDays2 | ||
fallthrough | ||
case 10: | ||
totalDays += monthDays2 | ||
fallthrough | ||
case 9: | ||
totalDays += monthDays2 | ||
fallthrough | ||
case 8: | ||
totalDays += monthDays2 | ||
fallthrough | ||
case 7: | ||
totalDays += monthDays2 | ||
fallthrough | ||
case 6: | ||
totalDays += monthDays1 | ||
fallthrough | ||
case 5: | ||
totalDays += monthDays1 | ||
fallthrough | ||
case 4: | ||
totalDays += monthDays1 | ||
fallthrough | ||
case 3: | ||
totalDays += monthDays1 | ||
fallthrough | ||
case 2: | ||
totalDays += monthDays1 | ||
fallthrough | ||
case 1: | ||
totalDays += monthDays1 | ||
|
||
} | ||
|
||
println("Total days: ", totalDays) | ||
} |