[Ruby] Programming with ruby (on the way)

1 minute read

Is the output

I am programming using ruby by making use of what I learned last time.

Although it is still in the middle, this time I would like to make a profit calculation for the store that I learned with MUP. Actually, it seems that the plan to finish quickly will be longer than I expected. .. ..

For the time being, the following is on the way

def input_data(total_datas)
  puts "Please enter the store name"
    store_name = gets.chomp
  puts "Number of customers for weekday lunch"
    weekday_lunch_guest = gets.to_i
  puts "Number of guests for weekday dinner"
    weekday_dinner_guest = gets.to_i
  puts "Number of holiday lunch guests"
    weekend_lunch_guest = gets.to_i
  puts "Number of holiday dinner guests"
    weekday_dinner_guest = gets.to_i
  puts "Price per weekday lunch"
    weekday_lunch_guest_price = gets.to_i
  puts "Price per weekday dinner"
    weekday_dinner_guest_price = gets.to_i
  puts "holiday lunch unit price"
    weekend_lunch_guest_price = gets.to_i
  puts "holiday dinner unit price"
    weekend_dinner_guest_price = gets.to_i
  puts "weekday business days"
    weekday_business = gets.to_i
  puts "holiday business days"
    weekend_business = gets.to_i
  puts "cost of lunch"
    lunch_cost = gets.to_i
  puts "cost of dinner"
    dinner_cost = gets.to_i
  puts "Please enter rent"
    rent = gets.to_i
  puts "Please enter the utility bill"
    utility_cost = gets.to_i
  puts "Enter labor costs"
    saraly = gets.to_i
  puts "Please enter monthly purchases"
    stocking = gets.to_i

  total_data = {store_name: store_name, weekday_lunch_guest: weekday_lunch_guest, weekday_dinner_guest: weekday_dinner_guest, weekend_lunch_guest: weekend_lunch_guest, weekday_dinner_guest: weekday_dinner_guest, weekday_lunch_guest_price: weekday_lunch_guest_price, weekday_dinner_guest_price: weekday_dinner_guest_price, weekend_lunch_guest_price: weekend_lunch_guest_price, weekend_dinner_guest_price: weekend_dinner_guest_price, weekday_business: weekday_business, weekend_business: weekend_business, lunch_cost: lunch_cost , dinner_cost: dinner_cost, rent: rent, utility_cost: utility_cost, saraly: saraly, stocking: stocking}

  total_datas << total_data
end

def show_store(total_datas)
  total_datas.each_with_index do |total_data, i|
    puts "[#{i}]: #{total_data[:store_name]}"
  end

  puts "Please enter the number you want to confirm."
  input = gets.to_i
  total_data = total_datas[input]

  if total_data
    show_data(total_data)
  else
    puts "No corresponding number"
  end
end

def show_data(total_data)
end




def end_program
  exit
end

def exception
  puts "The value entered is an invalid value"
end

total_datas = []

while true do
  puts "Please enter the number"
  puts "Register [0] store"
  puts "[1] Refer to data"
  puts "[2] Terminate the application"
    input = gets.to_i

  if input == 0 then
    input_data
  elsif input == 1 then
    show_store(total_datas)
  elsif input == 2 then
    end_program
  else
    exception
  end
end

with show_data(total_data) I would like to calculate the numerical value of the value in the hash sequentially and finally make a profit forecast. Well Excel is quicker, but lol

Tags:

Updated: