Go vet in practice

Report a typo

Let's create a simple future salary calculator. The program prints the current salary of the user, the desired salary, and the tax amount after the desired salary. Below is the code for the project, however, it does not work properly. Use the needed tool to find the mistake in the code and modify it accordingly.

package main

import (
	"fmt"
)

func main() {
	// needed data for the project
	// Enter your current salary
	var current_salary float32
	fmt.Scanln(&current_salary)
	// Enter how much percentage you want to add to your salary
	var percentage float32
	fmt.Scanln(&percentage)
	// Enter the total percentage of taxation
	var tax_percentage float32
	fmt.Scanln(&tax_percentage)
	// new calculation
	new_salary := current_salary * (1 + percentage/100)
	new_tax := new_salary * (1 - tax_percentage/100)
	// texts for output
	text_1 := "your current salary is " + fmt.Sprintf("%v", current_salary)
	text_2 := "your new salary is " + fmt.Sprintf("%v", new_salary)
	text_3 := "then you need to pay for tax " + fmt.Sprintf("%v", new_tax)
	// output
	fmt.Printf("%f", text_1)
	fmt.Printf("%f", text_2)
	fmt.Printf("%f", text_3)
}

Sample Input 1:

100000
20
10

Sample Output 1:

your current salary is 100000
your new salary is 120000.01
then you need to pay for tax 108000.01
Write a program in Go
package main

import (
"fmt"
)

func main() {
// put your code here

}
___

Create a free account to access the full topic