Visualg algorithm error - Simple average calculation and rating - Beginner

Asked

Viewed 285 times

-1

I’m a beginner and I’m learning algorithms.

I started to make an algorithm for calculating simple average and also a classification based on average, but visualg accuses a series of errors in the syntax that I can’t identify.

If anyone can help me I would be very grateful

Thank you from now on and I ask for forgiveness if it is very elementary, I am very beginner.

Below is the algorithm:

'algoritmo "Media"
var

n1, n2, m: real
clf : caractere

// O objetivo é calcular a média simples das notas e fazer uma classificação


inicio

EscrevaL ("---------------------------")
EscrevaL ("")
EscrevaL ("")
EscrevaL ("     ESCOLA DO JUBERNAL")
EscrevaL ("")
EscrevaL ("")
EscrevaL ("---------------------------")
EscrevaL ("")
EscrevaL ("Seja bem vindo")
EscrevaL ("Escreva a primeira nota: ")
Leia (n1)
EscrevaL ("Escreva a segunda nota: ")
Leia (n2)
m <- (n1 + n2) / 2
EscrevaL ("SUA MÉDIA DAS NOTAS É:", m, " !")

se (m >= 9) e (m <=10) entao
   clf <- A
senao
   se (m >= 7) e (m < 9) entao
      clf <- B
   senao
      se (m >= 5) e (m < 7) entao
         clf <- C
      senao
         se (m >= 3) e (m < 5) entao
            clf <- D
         senao
            se (m >= 1) e (m < 3) entao
               clf <- Ê
            senao
               clf <- F
            fimse
         fimse
      fimse
   fimse
fimse


EscrevaL ("-------------------------------------")
EscrevaL ("")
EscrevaL ("           SITUAÇÃO FINAL ")
EscrevaL ("")
EscrevaL ("-------------------------------------")
EscrevaL ("")
EscrevaL ("")
EscrevaL ("SUA MÉDIA DAS NOTAS É:", m, " !")
EscrevaL ("APROVEITAMENTO DO ALUNO:", clf, " !")
se (clf = a ou b ou c) entao
   EscrevaL ("SITUAÇÃO: APROVADO!")
senao
   EscrevaL ("SITUAÇÃO: REPROVADO!")
Fimse
EscrevaL ("")
EscrevaL ("")
EscrevaL ("-------------------------------------")


fimalgoritmo'

1 answer

1

Hello, Carlos!

Well, there’ll be two of us starting then, because you’re the first person I answer to here! :)

Let’s see if I can help you.

Well, first of all, when assigning character values in Visualg (and most major programming languages), we need to always put these values in quotes. So the correct syntax for the parts corresponding to this situation is:

clf <- "A"

The other mistake I found was the part about compound logic testing. I believe it was just a mistake of yours writing this part of the code, after all in a previous passage you had already written correctly. The correct syntax for this chunk of code is:

se (clf = "A") ou  (clf = "B") ou (clf = "C") entao

Note that I have already taken the liberty of correcting the character assignments with their quotation marks.

Make these two corrections in the code and check if the errors have been fixed there in your compiler. Here in my worked perfectly!

Good studies!

  • Thanks for the help!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.