package main
import (
"fmt"
"strings"
)
func main() {
var conferenceName string = "RK's conference"
const conferenceDate string = "3rd of July 2023"
var remainingTickets uint = 50
bookings := []string{}
// fmt.Printf("conferenceNamae is %T, conferenceDate is %T and remainingTickets is %T", conferenceName, conferenceDate, remainingTickets)
fmt.Printf("Welcome to the %v!! the confernece is going to be organized on the date of %v. Hurry up we have only %v of tickets left in the process\n", conferenceName, conferenceDate, remainingTickets)
for {
var firstName string
var lastName string
var email string
var userTickets int
fmt.Println("Enter your first name:")
fmt.Scan(&firstName)
fmt.Println("Enter your last name:")
fmt.Scan(&lastName)
fmt.Println("Enter number of tickets:")
fmt.Scan(&userTickets)
fmt.Println("Enter your email address:")
fmt.Scan(&email)
remainingTickets = remainingTickets - uint(userTickets)
// bookings[0] = firstName + " " + lastName
bookings = append(bookings, firstName + " " + lastName)
// slices are more dynamic in size and called as abstrction of size
fmt.Printf("Thank you %v %v for booking %v tickets. You will receive a confirmation email at %v. Thank you! \n", firstName, lastName, userTickets, email)
fmt.Printf("Remaining tickets are %v \n", remainingTickets)
firstNames := []string{}
for _, booking := range bookings {
var names = strings.Fields(booking)
firstNames = append(firstNames, names[0])
}
fmt.Printf("The first names of bookings are %v \n", firstNames)
fmt.Printf("These are all our bookings: %v \n", bookings)
}
}| Associated Context | |
|---|---|
| Type | Code Snippet ( .go ) |
| Associated Tags | Remaining Tickets Functional Programming Bookings Array Conference Name Array and Slice String Manipulation Conference Date Dynamic Size User Tickets Data Structures User Booking Conference Registration Framework:None. Email Confirmation C# Programming User Input Go Programming Language Constants Ticket Availability |
| 💡 Smart Description | The code creates a conference with a name, date, and number of tickets. It then prompts users to enter their information and books tickets for them until all tickets are sold out, storing each booking in a slice. It also prints the remaining tickets and This code snippet creates a list of bookings with their first name, last name, email address, and remaining tickets. It then prints the number of tickets left in the process to print |
| 🔎 Suggested Searches | Go programming language conference registration RK's conference 2023 tickets Conference booking with Go programming language Register for RK's conference Go programming language event booking program to find bookings with conferenceNamae and user tickets How to create a list of tickets in programming using C++ Code for creating an array of participants from the current date or email address programming code for finding bookmarks that are not yet available at this time? |
| Related Links | https://golangbyexample.com/ https://www.geeksforgeeks.org/data-structures/linked-list/ https://www.tutorialspoint.com/go/index.htm https://www.golang-book.com/ https://www.geeksforgeeks.org/ https://www.hackerearth.com/practice/data-structures/hash-tables/basics-of-hash-tables/tutorial/ https://golangbot.com/ https://www.geeksforgeeks.org/what-is-linked-list/ https://gobyexample.com/reading-files https://golangdocs.com/ https://gobyexample.com/ https://www.calhoun.io/ https://www.codesdope.com/course/data-structures-linked-lists/ https://www.golangprograms.com/ |
| Related People | No Related People |
| Sensitive Information | No Sensitive Information Detected |
| Shareable Link | https://c11a5e20-8e1a-41da-83d8-3d90075c3ff1.pieces.cloud/?p=877945a6cb |