initial commit
This commit is contained in:
commit
fa67559df6
|
@ -0,0 +1,120 @@
|
|||
|
||||
# Created by https://www.gitignore.io/api/vim,linux,macos,windows,go
|
||||
# Edit at https://www.gitignore.io/?templates=vim,linux,macos,windows,go
|
||||
|
||||
### Go ###
|
||||
# Binaries for programs and plugins
|
||||
*.exe
|
||||
*.exe~
|
||||
*.dll
|
||||
*.so
|
||||
*.dylib
|
||||
|
||||
# Test binary, built with `go test -c`
|
||||
*.test
|
||||
|
||||
# Output of the go coverage tool, specifically when used with LiteIDE
|
||||
*.out
|
||||
|
||||
# Dependency directories (remove the comment below to include it)
|
||||
# vendor/
|
||||
|
||||
### Go Patch ###
|
||||
/vendor/
|
||||
/Godeps/
|
||||
|
||||
### Linux ###
|
||||
*~
|
||||
|
||||
# temporary files which can be created if a process still has a handle open of a deleted file
|
||||
.fuse_hidden*
|
||||
|
||||
# KDE directory preferences
|
||||
.directory
|
||||
|
||||
# Linux trash folder which might appear on any partition or disk
|
||||
.Trash-*
|
||||
|
||||
# .nfs files are created when an open file is removed but is still being accessed
|
||||
.nfs*
|
||||
|
||||
### macOS ###
|
||||
# General
|
||||
.DS_Store
|
||||
.AppleDouble
|
||||
.LSOverride
|
||||
|
||||
# Icon must end with two \r
|
||||
Icon
|
||||
|
||||
# Thumbnails
|
||||
._*
|
||||
|
||||
# Files that might appear in the root of a volume
|
||||
.DocumentRevisions-V100
|
||||
.fseventsd
|
||||
.Spotlight-V100
|
||||
.TemporaryItems
|
||||
.Trashes
|
||||
.VolumeIcon.icns
|
||||
.com.apple.timemachine.donotpresent
|
||||
|
||||
# Directories potentially created on remote AFP share
|
||||
.AppleDB
|
||||
.AppleDesktop
|
||||
Network Trash Folder
|
||||
Temporary Items
|
||||
.apdisk
|
||||
|
||||
### Vim ###
|
||||
# Swap
|
||||
[._]*.s[a-v][a-z]
|
||||
[._]*.sw[a-p]
|
||||
[._]s[a-rt-v][a-z]
|
||||
[._]ss[a-gi-z]
|
||||
[._]sw[a-p]
|
||||
|
||||
# Session
|
||||
Session.vim
|
||||
Sessionx.vim
|
||||
|
||||
# Temporary
|
||||
.netrwhist
|
||||
|
||||
# Auto-generated tag files
|
||||
tags
|
||||
|
||||
# Persistent undo
|
||||
[._]*.un~
|
||||
|
||||
# Coc configuration directory
|
||||
.vim
|
||||
|
||||
### Windows ###
|
||||
# Windows thumbnail cache files
|
||||
Thumbs.db
|
||||
Thumbs.db:encryptable
|
||||
ehthumbs.db
|
||||
ehthumbs_vista.db
|
||||
|
||||
# Dump file
|
||||
*.stackdump
|
||||
|
||||
# Folder config file
|
||||
[Dd]esktop.ini
|
||||
|
||||
# Recycle Bin used on file shares
|
||||
$RECYCLE.BIN/
|
||||
|
||||
# Windows Installer files
|
||||
*.cab
|
||||
*.msi
|
||||
*.msix
|
||||
*.msm
|
||||
*.msp
|
||||
|
||||
# Windows shortcuts
|
||||
*.lnk
|
||||
|
||||
# End of https://www.gitignore.io/api/vim,linux,macos,windows,go
|
||||
messing_around
|
|
@ -0,0 +1,3 @@
|
|||
module code.chrissexton.org/cws/messing_around
|
||||
|
||||
go 1.14
|
|
@ -0,0 +1,34 @@
|
|||
package main
|
||||
|
||||
import "fmt"
|
||||
|
||||
func main() {
|
||||
originalPrice := 0.0
|
||||
discount := 0.0
|
||||
|
||||
fmt.Printf("Enter the price of the item: ")
|
||||
_, err := fmt.Scanf("%f", &originalPrice)
|
||||
if err != nil {
|
||||
fmt.Printf("Invalid price: %s\n", err)
|
||||
return
|
||||
}
|
||||
|
||||
fmt.Printf("Enter the percentage off: ")
|
||||
_, err = fmt.Scanf("%f", &discount)
|
||||
if err != nil {
|
||||
fmt.Printf("Invalid discount: %s\n", err)
|
||||
return
|
||||
}
|
||||
|
||||
salePrice, percentOff := getSalePrice(originalPrice, discount)
|
||||
|
||||
fmt.Printf("The percent off is %.2f.\nThe Price will be: %.2f\n", percentOff, salePrice)
|
||||
}
|
||||
|
||||
func getSalePrice(originalPrice, discount float64) (float64, float64) {
|
||||
percentOff := discount / 100.0
|
||||
adjustedPrice := originalPrice * percentOff
|
||||
salePrice := originalPrice - adjustedPrice
|
||||
|
||||
return salePrice, percentOff
|
||||
}
|
Loading…
Reference in New Issue