0
The code below is for my first college program. What do I call the given of one function within another??? I need these 3 functions for the delivery of the program, but error appears
""Error in notamf(mf) : p object not found""
Obs.: When I enter -1 in some proof, P1 or P2, the result to be considered is the substitute proof grade...
Obs2.: there is a comment on the last line, because the student’s situation is not fulfilled after calculating mf (final average)
n <- as.numeric(readline("Digite o numero de alunos na sala: "))
for (i in 1:n) {
nome <- readline("Digite o nome do aluno: ")
p1<- as.numeric(readline("Digite a nota da P1: "))
p2<- as.numeric(readline("Digite a nota da P2: "))
psub<- as.numeric(readline("Digite a nota da PSub: "))
ep1<- as.numeric(readline("Digite a nota do EP1: "))
ep2<- as.numeric(readline("Digite a nota do EP2: "))
ep3<- as.numeric(readline("Digite a nota do EP3: "))
notap <- function(p){
if(p1== -1){
p<-as.numeric((p2+psub)/2)
}else if(p2== -1){
p<-as.numeric((p1+psub)/2)
}else{
p <-as.numeric((p1+p2)/2)
}
return(p)
}
notaep <- function(ep){
ep <- (ep1 + 2*ep2 + 2*ep3)/5
return(ep)
}
notamf <- function(mf){
if(p>=5 && ep>=5){
mf <- (3*p+ep)/4
}else{
if(p>ep){
mf <- ep
}else{
mf <- p
}
}
return(mf)
}
print(paste0("nome = ", nome))
print(paste0("P1= ",p1))
print(paste0("P2= ",p2))
print(paste0("PSub= ",psub))
print(paste0("A média das provas P= " , notap(p)))
print(paste0("A média dos EPs, EP= ", notaep(ep)))
print(paste0("A média final, MF= ", notamf(mf)))
#print(paste0("A situação do aluno ", nome , " é ", situacao))
}