Menu
CoddyTech

계산서 나누기

Coddy GDScript 여정의 기초 섹션에 포함된 레슨. 92개 중 41번째.

challenge icon

챌린지

쉬움

분할 기능을 추가하세요. 이전 단계의 모든 내용을 유지하고 다음을 수행하세요.

  1. 세 번째 입력인 계산서를 나누어 낼 사람 수를 읽고, int로 변환하여 num_people에 저장하세요. 팁 비율을 읽은 직후에 읽으세요.
  2. total_amount를 num_people으로 나누어 amount_per_person을 계산하세요.
  3. total_amount를 출력하는 줄 다음에 amount_per_person을 출력하세요.

레이블 없이 숫자만 출력하세요. 예를 들어, 입력값이 64.3, 9.0, 2이면 프로그램은 다음을 출력합니다.

Bill Split Calculator
70.087
35.0435

직접 해보기

extends Node

func _ready():
	print("Bill Split Calculator")

	var bill_amount := float(OS.read_string_from_stdin())
	var tip_percentage := float(OS.read_string_from_stdin())

	var tip_amount := (tip_percentage / 100) * bill_amount
	var total_amount := bill_amount + tip_amount

	print(total_amount)

기초의 모든 레슨

직접 연습해 보세요: 온라인 GDScript 컴파일러