Question 1 . Please use the Problem Solving Process. Include UML Class and Activ
ID: 3683516 • Letter: Q
Question
Question 1 . Please use the Problem Solving Process. Include UML Class and Activity Diagrams
Write an application that takes in an Array of 30 Grades (integer) and returns the maximum grade, minimum grade, average of all grades, and prints a Bar Chart to show the grade distribution. Note; maximum grade, minimum grade, average grade, and the Bar Chart must use implemented as separate methods.
Question 2. Please use the Problem Solving Process. Include UML Class and Activity Diagrams.
Write a java application that first read in the size of a one dimensional array, read in each array element of double type, reverses the order of this one-dimensional array. Do not create another array to hold the result.
Question 3. Please use the Problem Solving Process. Include UML Class and Activity Diagrams.
Write a java application to sort an integer array. Assume you have an integer array with n elements. Use a selection sort algorithm to sort the elements in the array in increasing order.
Selection sort algorithm always finds the minimum or maximum element in the unsorted set of elements and make them in the order.
For example, if you have an array {3, 2, 9, 5, 4, 6}
First round, you find 2, the minimum in the unsorted set {3, 2, 9, 5, 4, 6}, switch 2 with the first element of the array which is 3, you get {2, 3, 9, 4, 5, 6}
Second round, you find 3, the minimum in the unsorted set from {3, 9, 5, 4, 6}
Continue above process until the array is sorted.
Please Help !!!
Explanation / Answer
#include <stdio.h>
#include <stdlib.h>
#include <float.h>
#include <graphics.h>
#include <math.h>
#include <conio.h>
#define MAX 100
#define ARRAYMAX 5
void makegraph(float p[]);
void main(void)
{
int i;
int scores[ARRAYMAX];
float percents[ARRAYMAX];
int max_score,min_score,sum=0;
float avg_score;
for (i = 0; i < ARRAYMAX; i++)
{
printf(" Enter score between 0 and %d: ", MAX);
scanf("%d", &scores[i]);
}
max_score=scores[0];
min_score=scores[0];
sum=scores[0];
for (i = 1; i < ARRAYMAX; i++)
{
if(max_score<scores[i])
max_score=scores[i];
if(min_score>scores[i])
min_score=scores[i];
sum+=scores[i];
percents[i] = ((float) scores[i]) / MAX;
}
avg_score=sum/30.0;
printf(" SCORE PERCENT");
for (i = 0; i < ARRAYMAX; i++)
printf(" %d. %d %3.0f", i + 1, scores[i], (percents[i] * 100));
printf (" Max Gardes = %d ",max_score);
printf (" Min Gardes = %d ",min_score);
printf(" Average Grades = %f",avg_score);
getch();
makegraph(percents);
}
void makegraph(float p[])
{
int g_driver, g_mode;
int i, left, top, wide, bottom, deep;
detectgraph(&g_driver, &g_mode);
initgraph(&g_driver, &g_mode, "C:\tc ");
wide = (int)((getmaxx()) / ((ARRAYMAX * 2 ) + 1));
bottom = getmaxy() - 20;
deep = (int) (wide / 4);
left = wide;
for (i = 0; i < ARRAYMAX; i++)
{
top = (bottom) - ((int)(p[i] * 300));
bar3d(left, top, (left + wide), bottom, deep, 1);
left += (wide * 2);
}
getch();
closegraph();
return;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.