GPA Calculator

By: Siddharth Chadha
Date: 03/11/2020

Introduction

This app calculates the GPA of a student after the student enters his marks details. The app also plots his score which is credit sensitve, which gives the student an idea about his progess.

The app takes in the data of three subjects.

Link to the app: https://siddharthchadha625.shinyapps.io/GPA_Calculator/

About the APP

The app consists of an user interface part and the server part of the app.

Inputs:

  • Subject marks out of 10
  • Number of credits allotted to the subject (max: 5).

Outputs:

  • Calculated GPA
  • Credit Sensitive Score Plot

Application Widgets

Inputs

  • numericInput() : Accepts numeric input from the user
  • sliderInput() : Accepts input from the user through a slider widget

Output

  • renderText() : Outputs plain simple text after the server calculations
  • renderPlot() : Outputs a plot for graphical visualization

Code Section : ui.R

library(shiny)

shinyUI(fluidPage(

    titlePanel("GPA Calculator"),

    sidebarLayout(
        sidebarPanel(
            h5("Subject 1"),
            sliderInput("subject1","Input the marks of subject 1 from 0 to 10",0,10,0),
            numericInput("credit1","Input the credits of the subject", value = 0, min=1, max=5, step=1),

            h5("Subject 2"),
            sliderInput("subject2","Input the marks of subject 2 from 0 to 10",0,10,0),
            numericInput("credit2","Input the credits of the subject", value = 0, min=1, max=5, step=1),

            h5("Subject 3"),
            sliderInput("subject3","Input the marks of subject 3 from 0 to 10",0,10,0),
            numericInput("credit3","Input the credits of the subject", value = 0, min=1, max=5, step=1),
        ),

        mainPanel(
            h3("The calculated GPA of the student is: "),
            textOutput("ans"),

            h3("Credit Sensitive Score Plot"),
            plotOutput("plot1")
        )
    )
))

Code Section : server.R

library(shiny)

shinyServer(function(input, output) {


    output$ans = renderText(((input$subject1)*(input$credit1) + (input$subject2)*(input$credit2) + (input$subject3)*(input$credit3))/((input$credit1) + (input$credit2) + (input$credit3)))

    output$plot1 <- renderPlot({

        dataY <- c(input$subject1, input$subject2, input$subject3)
        dataZ <- c(input$cedit1, input$credit2, input$credit3)
        dataX <- c("Subject 1", "Subject 2" ,"Subject 3")
        finaldata <- c((input$subject1)*(input$credit1) , (input$subject2)*(input$credit2) , (input$subject3)*(input$credit3))
        df <- data.frame(dataX,dataY)

        barplot(finaldata, ylim = c(0,50), names.arg = c("Subject 1", "Subject 2", "Subject 3"), col ="green", ylab = "Score", xlab = "Subjects")
    })

})