From 52981498f5b39d450344fc6aa5d7a16f5b61f86e Mon Sep 17 00:00:00 2001 From: sinalalebakhsh Date: Sat, 28 Oct 2023 07:33:28 -0400 Subject: [PATCH] Add a feature for Question/Answer from user --- features/Answers.go | 1 + features/AnswersSample.go | 6 ++++++ features/Questions.go | 1 + features/QuestionsSample.go | 4 ++++ 4 files changed, 12 insertions(+) diff --git a/features/Answers.go b/features/Answers.go index ec280bf..f927eae 100644 --- a/features/Answers.go +++ b/features/Answers.go @@ -6,6 +6,7 @@ type AllAnswers struct { var Answers = AllAnswers{ SingleAnws: map[string]string{ + "operator": "Hints and Tips Calculate the number of working cars produced per hour The percentage (passed as an argument) is a number between 0-100. To make this percentage a bit easier to work with, start by dividing it by 100. To compute the number of cars produced successfully, multiply the percentage (divided by 100) by the number of cars produced. When multiplying two numbers together, they both need to be of the same type. Use type conversions if needed.", "operator 1": "Hints and Tips Calculate the number of working cars produced per hour The percentage (passed as an argument) is a number between 0-100. To make this percentage a bit easier to work with, start by dividing it by 100. To compute the number of cars produced successfully, multiply the percentage (divided by 100) by the number of cars produced. When multiplying two numbers together, they both need to be of the same type. Use type conversions if needed.", }, } diff --git a/features/AnswersSample.go b/features/AnswersSample.go index 3e8e11c..c2bd0e1 100644 --- a/features/AnswersSample.go +++ b/features/AnswersSample.go @@ -6,6 +6,12 @@ type AnswersSampleStruct struct { var AnswersSample = AnswersSampleStruct { MapAnswersSample: map[string]string { + "operator": `// CalculateWorkingCarsPerHour calculates how many working cars are +// produced by the assembly line every hour. +func CalculateWorkingCarsPerHour(productionRate int, successRate float64) float64 { + last := float64(productionRate) * successRate / 100 + return last +}`, "operator 1": `// CalculateWorkingCarsPerHour calculates how many working cars are // produced by the assembly line every hour. func CalculateWorkingCarsPerHour(productionRate int, successRate float64) float64 { diff --git a/features/Questions.go b/features/Questions.go index 1a437ef..15e4e92 100644 --- a/features/Questions.go +++ b/features/Questions.go @@ -6,6 +6,7 @@ type AllQuestions struct { var Questions = AllQuestions{ SingleQues: map[string]string{ + "operator":"The cars are produced on an assembly line. The assembly line has a certain speed, that can be changed. The faster the assembly line speed is, the more cars are produced. However, changing the speed of the assembly line also changes the number of cars that are produced successfully, that is cars without any errors in their production. Implement a function that takes in the number of cars produced per hour and the success rate and calculates the number of successful cars made per hour. The success rate is given as a percentage, Note: the return value should be a float64, from 0 to 100:", "operator 1":"The cars are produced on an assembly line. The assembly line has a certain speed, that can be changed. The faster the assembly line speed is, the more cars are produced. However, changing the speed of the assembly line also changes the number of cars that are produced successfully, that is cars without any errors in their production. Implement a function that takes in the number of cars produced per hour and the success rate and calculates the number of successful cars made per hour. The success rate is given as a percentage, Note: the return value should be a float64, from 0 to 100:", }, } diff --git a/features/QuestionsSample.go b/features/QuestionsSample.go index ce8669d..9596914 100644 --- a/features/QuestionsSample.go +++ b/features/QuestionsSample.go @@ -7,6 +7,10 @@ type QuestionsSampleStruct struct { var QuestionsSample = QuestionsSampleStruct { MapQuestionsSample: map[string]string{ + "operator":`Sample: +CalculateWorkingCarsPerHour(1547, 90) +expect: +// => 1392.3`, "operator 1":`Sample: CalculateWorkingCarsPerHour(1547, 90) expect: