Would anyone be able to help me with my project? Im stuck

(junior) #1

Write a Go program that does the following:

implement a array/slice-based spreadsheet program that:

  • has 5 arrays or slices of 5 float64 values in each – these are the spreadsheet rows
  • has 1 operations array or slice of 5 string values – these are the operations associated with each of the 5 rows
  • has 1 calculations array or slice of 5 float64 values – these are the calculated values (based on operation) for each of the 5 rows
  • required operations – SUM of values in a row, AVERAGE of values in a row, MINIMUM value in a row, MAXIMUM value in a row
  • required functionality – edit a specified cell in a specified row, change the operation in a row, clear one row of all data, clear all rows of all data, exit the program
  • implement robust user input handling (i.e., prevent the user from entering invalid values
  1. what the running program should do to demonstrate all functionality:
  • loop until the user chooses to exit the program
  • display the data in all rows, including the calculated value and operation for each row
  • show a menu of all options (edit/change operation, clear row, clear all rows, exit program)
  • allow the user to select from the menu options and carry out the desired function

This is my code so far, not much but any help would be greatly appreciated!
My main problem , is doing the operations for every row. Not quite sure how i would add up all the row

Sorry for the mess

package main

import (“fmt”
func ClearScreen() {
cmd := exec.Command(“cmd”, “/c”, “cls”)
switch runtime.GOOS {
case “linux”:
cmd = exec.Command(“clear”)
case “darwin”:
cmd = exec.Command(“clear”)
cmd.Stdout = os.Stdout
func PrintRow(rowNum int, theRow [5]float64, calc float64, op string){

fmt.Printf("%d:", rowNum)
for _, value := range theRow {
fmt.Printf("%8.2f “, value)
fmt.Printf(” | %.2f(%s)",calc, op)
func editcell(row []float64, index int){
fmt.Printf("Enter new value(current=%.2f): ", row[index])

func main() {

var row1, row2, row3, row4, row5 [5]float64
var calc [5]float64
var ops [5] string

var quit bool
for quit ==false{
PrintRow(1, row1, calc[0], ops [0])
PrintRow(2, row2, calc[1], ops [1])
PrintRow(3, row3, calc[2], ops [2])
PrintRow(4, row4, calc[3], ops [3])
PrintRow(5, row5, calc[4], ops [4])

fmt.Printf("[1] Edit cell\n")
fmt.Printf("[2] Change operation for row\n")
fmt.Printf("[3] Clear one row\n")
fmt.Printf("[4] Clear all rows\n")
fmt.Printf("[5] Exit Program\n")

var choice int
fmt.Printf("\n Your choice: ")

//menuChoice :=1
switch choice {
case 1:
  fmt.Printf("Row number? (1-5)")
  var rowNumber int

  fmt.Printf("Column number (0-4)? ")
  var columnNumber int

  if rowNumber ==1 {
    editcell (row1[:],columnNumber)
    //use row1
  }else if rowNumber ==2{
    //use row2
  }else if rowNumber ==3{
  //use row3
}else if rowNumber ==4{
  //use row4
} else if rowNumber ==5{
case 2:
  fmt.Printf("Row number? (1-5)?")
  var row int

  if row ==1{
  fmt.Printf("Which operation would you like? 1: SUM , 2 :AVERAGE , 3 : MINIMUM , 4: MAX \n")
  var op int

example of how it should look like

(Lutz Horn) #2

What does your program do so far? Which of the requirements do you have implemented?

(junior) #3

I have the menu done and am able to edit the values for any row/column, right now I am trying get it to do the operations of the values of a row