Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

intro to java..keep it simple. I already started working on it *see below* please follow the same format and variables.no extra import, only the ones

intro to java..keep it simple. I already started working on it *see below* please follow the same format and variables.no extra import, only the ones I have below. thank you!! i can't figure out :(

*****************************************************************THE PROGRAM**********************************************************************************************

image text in transcribed

SUBJECT: Selection, Loops, Program Design

Given:

A file that contains a student name and a grade on exam1 and grade on exam2 for 25 students. File above

Write a program that gives the user the choice of the following calculations:

Class Average (exam1, exam2)

Student Average (all 25 students)

Standard Deviation (exam1, exam2)

Letter grades (all 25 students)

Minimum/Maximum (for each exam and the students who got them),

Locate : given a student name find the grades

Locate All students where the difference between exam1 and exam2>15%

Histogram

Update data (enter name, new test scores)

Quit

Requirements:

You must use :

1) at least one event controlled loop for a calculation

2) one count controlled while loop for a calculation

3) one for loop for a calculation

4) you should include appropriate error messages (one of the problems)

To make sure you meet all of these requirements and to make it easy for me to find, label

them as follows (before loop) This is in addition to any other appropriate comments

//**********************************************

// #1 Event controlled loop

//**********************************************

Assumptions

You can assume that there is only one maximum and only one minimum grade (no ties)

Assume the student name may or may not have a space in it.

Program layout/comments will be especially important.

****************************************************THIS IS WHAT I HAVE SO FAR, MUST BE THIS WAY OR SIMILAR****************************************************

import java.text.DecimalFormat;

import java.util.Scanner;

import javax.swing.JOptionPane;

import java.io.* ;

public class Lab

{

public static void main (String [] args) throws IOException

{

Scanner kb = new Scanner (System.in);

File myFile = new File ("Labgrades.txt");

Scanner inFile = new Scanner (myFile);

int sCount,menu;

float grade1,grade2,sumOne,sumTwo,avg1,avg2,examOne,examTwo,x,y,min,max,min1,max1;

String stuName,strOne,str,name,mx,mn,mx1,mn1,n1,n2,n3,n4;

System.out.println(" 1: Class Average");

System.out.println(" 2: Student Average");

System.out.println(" 3: Standard Deviation");

System.out.println(" 4: Letter Grades");

System.out.println(" 5: Minimum/Maximum");

System.out.println(" 6: Locate: Specific Student Grade");

System.out.println(" 7: Locate Larger Difference in Grades for Test 1 and Test 2");

System.out.println(" 8: Histogram");

System.out.println(" 9: Update Data");

System.out.println(" 10: Quit");

System.out.println("Pick an Option");

menu = kb.nextInt();

switch(menu)

{

case 1 : System.out.println ("your picked 1");

System.out.println(" 1: Class Average");

sCount=1;

sumOne=0;

sumTwo=0;

inFile.nextLine();

while(sCount

{

str=inFile.nextLine();

name=str.substring(0,25).trim();

strOne=str.substring(25,35).trim();

examOne=Float.parseFloat(strOne);

strOne=str.substring(35,45).trim();

examTwo=Float.parseFloat(strOne);

sumOne=sumOne+examOne;

sumTwo=sumTwo+examTwo;

sCount ++;

}

avg1=sumOne/25;

avg2=sumTwo/25;

System.out.printf("The Average for the first Exam is %10.2f ",avg1);

System.out.printf("The Average for the second Exam is %9.2f ",avg2);

break;

case 2 : System.out.println ("your picked 2");

System.out.println(" 2: Student Average");

sumOne=0;

sumTwo=0;

inFile.nextLine();

sCount=0;

System.out.printf("%-20s %10s ","Name","Score");

for(sCount=0;sCount

{

str=inFile.nextLine();

name=str.substring(0,25).trim();

strOne=str.substring(25,35).trim();

examOne=Float.parseFloat(strOne);

strOne=str.substring(35,45).trim();

examTwo=Float.parseFloat(strOne);

sumOne=(examOne+examTwo)/2;

System.out.printf("%-20s %10.2f ",name,sumOne);

}

System.out.println("***************************************************************"+" ");

break;

Name George Washington John Adams Thomas Jefferson James Madison James Monroe John Quincy Adams Andrew Jackson Martin Van Buren William H. Harrison John Tyler James K. Polk Zachary Taylor Millard Fillmore Franklin Pierce James Buchanan Abraham Lincoln Andrew Johnson Ulvsses S. Grant Rutherford B. Hayes James A. Garfield Chester A. Arthur Grover Cleveland Benjamin Harrison Grover Cleveland william McKinley Exam 1 90.1 58.2 52.8 76.1 61.7 95. 8 75.2 97.9 69.0 79.7 94.0 57.5 78.9 70.0 68.0 72.8 66.1 68.8 71.9 54.6 61.5 53.7 83.1 86.7 79.3 Exam 2 62.6 66.4 51.2 95.8 70.1 57.4 79.6 90.2 98.9 65.4 89.6 76.2 64.8 56.1 50.7 91.8 56.4 81.1 93.6 97.4 79.2 85.4 59.2 64.3 59.5 Name George Washington John Adams Thomas Jefferson James Madison James Monroe John Quincy Adams Andrew Jackson Martin Van Buren William H. Harrison John Tyler James K. Polk Zachary Taylor Millard Fillmore Franklin Pierce James Buchanan Abraham Lincoln Andrew Johnson Ulvsses S. Grant Rutherford B. Hayes James A. Garfield Chester A. Arthur Grover Cleveland Benjamin Harrison Grover Cleveland william McKinley Exam 1 90.1 58.2 52.8 76.1 61.7 95. 8 75.2 97.9 69.0 79.7 94.0 57.5 78.9 70.0 68.0 72.8 66.1 68.8 71.9 54.6 61.5 53.7 83.1 86.7 79.3 Exam 2 62.6 66.4 51.2 95.8 70.1 57.4 79.6 90.2 98.9 65.4 89.6 76.2 64.8 56.1 50.7 91.8 56.4 81.1 93.6 97.4 79.2 85.4 59.2 64.3 59.5

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Advances In Databases And Information Systems 14th East European Conference Adbis 2010 Novi Sad Serbia September 2010 Proceedings Lncs 6295

Authors: Barbara Catania ,Mirjana Ivanovic ,Bernhard Thalheim

2010th Edition

3642155758, 978-3642155758

More Books

Students also viewed these Databases questions

Question

5. A review of the key behaviors is included.

Answered: 1 week ago