Questions
Use Java Sample values from an experiment often need to be smoothed out. One simple approach...

Use Java

Sample values from an experiment often need to be smoothed out. One simple approach is to replace each value in an array with the average of the value and its two neighboring values (or one neighboring value if it is at either end of the array). Given a class Data with instance fields

private double[] values;
private double valuesSize;

implement a method

public void smooth()

that carries out this operation. You should not create another array in your solution.

In: Computer Science

I can not get the summary report to show in the output it just keeps running...

I can not get the summary report to show in the output it just keeps running after i enter the names, scores, and then / /. Can someone help me I am using codeblocks but I might be able to figure out even if you use another IDE>

This is my code

#include <iostream>

using namespace std;

int main()
{
string name;
double score =0;
int totalStudents = 0;
int A=0,B=0,C=0,D=0,F=0;
cout << "Enter student name" << endl;
cin >> name;

while (name!="//"){
cout << "Enter student score" << endl;
cin >> score;
if(score>=90){
A++;
cout<<name<<" "<<score<<" A"<<endl;
}
else if(score>=80&&score<90){
B++;
cout<<name<<" "<<score<<" B"<<endl;
}
else if(score>=70&&score<80){
C++;
cout<<name<<" "<<score<<" C"<<endl;
}
else if(score>=60&&score<70){
D++;
cout<<name<<" "<<score<<" D"<<endl;
}
else if (score>=0&&score<60) {
F++;
cout<<name<<" "<<score<<" F"<<endl;
}
cout << "Enter student name" << endl;
cin >> name;
totalStudents++;
}
cout << "Enter student name" << endl;
cin >> name;
cout << "Summary Report" << endl;
cout << "Total Students count " << totalStudents << endl;
cout << "A student count " << A << endl;
cout << "B student count " << B << endl;
cout << "C student count " << C << endl;
cout << "D student " << D << endl;
cout << "F students " << F << endl;
return 0;
}


This was the question

Topics

Loops

while Statement

Description

Write a program that computes the letter grades of students in a class from knowing their scores in a test. A student test score varies from 0 to 100. For a student, the program first asks the student’s name and the student’s test score. Then, it displays the student name, the test score and the letter grade. It repeats this process for each student. The user indicates the end of student data by entering two consecutive forward slashes ( // ) when asked for the student name. At the end, the program displays a summary report including the following:

·       The total number of students.

·       The total number of students receiving grade “A”.

·       The total number of students receiving grade “B”.

·       The total number of students receiving grade “C”.

·       The total number of students receiving grade “D”.

·       The total number of students receiving grade “F”.

The program calculates a student's the letter grade from the student's test score as follows:

A is 90 to 100 points

B is 80 to 89 points

C is 70 to 79 points

D is 60 to 69 points

F is 0 to 59 points.

Requirements

Do this exercise using a While statement and an If/Else If statement.

Testing

For turning in the assignment, perform the test run below using the input data shown

Test Run (User input is shown in bold).

Enter Student Name

Alan

Enter Student Score

75

Alan 75 C

Enter Student Name

Bob

Enter Student Score:

90

Bob 90 A

Enter Student Name

Cathy

Enter Student Score

80

Cathy 80 B

Enter Student Name

Dave

Enter Student Score:

55

Dave 55 F

Enter Student Name

Eve

Enter Student Score

85

Eve 85 B

Enter Student Name

//

Summary Report

Total Students count 5

A student count 1

B student count: 2

C student count 1

D student 0

F students 1

Sample Code

string name;

double score;

//Initias setup

cout << "Enter student name" << endl;

cin >> name;

//Test

while (name != "//")

{

    cout << "Enter student score" << endl;

    cin >> score;

    //more code here

    //Update setup

    out << "Enter student name" << endl;

    cin >> name;

}

//display summary report

In: Computer Science

Design, implement and verify a car buzzer that warns car passengers when the door is open...

Design, implement and verify a car buzzer that warns car passengers when the door is open or the seatbelt is not used whenever the car key is inserted in the ignition lock, written in VHDL code.

In: Computer Science

#include <stdio.h> const int DECK_SIZE = 52; int deck[DECK_SIZE]; int main(void) { /* Populate the deck...

#include <stdio.h>

const int DECK_SIZE = 52;

int deck[DECK_SIZE];

int main(void) {
/* Populate the deck */
for(int i = 0; i < DECK_SIZE; i++) {
deck[i] = i + 1;
}
  
/* Get the cut position as an integer input */
  
/* Verify that the input is valid */
  
/* Cut the deck */
  
/* Print the resulting deck with one element on each line */

return 0;
}

Write a program that "cuts" a deck of 52 playing cards. Given a cut position, the process of cutting the deck refers to taking all cards before the cut position and moving them to the end of the deck. The order of the cards is maintained. For example, if the deck is cut at position 25, the first 25 cards of the deck are moved to become the last 25 cards of the deck. The new first card in the deck is card 26, and the new last card of the deck is card 25.

The deck of cards is represented as a 52-element integer array, with values 1 through 52 representing the different cards. The initial population of the deck is done for you.

Your program should accept a single integer input, which is the cut position. If the input is less than 1 or greater than 52, your program should print "ERROR" and exit. Otherwise, after performing the cut, your program should print out the new deck, with one card value on each line.

Please use C language only. Please make it simple as this is an introductory C programming course

In: Computer Science

A museum's fee policy is that anyone who is either 12 and under or 65 and...

A museum's fee policy is that anyone who is either 12 and under or 65 and older receives free admission. Declare a boolean variable named freeAdmissionand set it based on the value in an integer variable age. To receive full credit you should only use one statement. Hint use boolean operators. in Java-Eclipes

In: Computer Science

In Python A child is required to use a booster seat in a car until the...

In Python

A child is required to use a booster seat in a car until the child is 9 years old, unless the child reaches the height of 59 inches before age 9. Which expression can be used to decide if a child requires a car seat or not?

a.

if age < 9 or height < 59:

b.

if age >= 9 or height >= 59:

c.

if age >= 9 and height >= 59:

d.

if age <= 9 and height <=59:

e.

None of the above

What conditions have to be true to make the following code display "B"?

if color == 'red':
    if style < 3:
        print('A')
    elif style < 5:
        print('B')
    else:
        print('C')
elif color == 'blue':
    print('D')

a.

color is 'blue' and style is 3

b.

color is 'red' and style is 6

c.

color is 'red' and style is 5

d.

color is 'red' and style is 4

e.

None of the above

What conditions have to be true to make the following code display "B"?

if color == 'red':
    if style < 3:
        print('A')
    elif style < 5:
        print('B')
    else:
        print('C')
elif color == 'blue':
    print('D')

a.

color is 'blue' and style is 3

b.

color is 'red' and style is 6

c.

color is 'red' and style is 5

d.

color is 'red' and style is 4

e.

None of the above

Which statement is equivalent to the following assignment?

x -= 2 + y

a.

x = 2 + y - x

b.

x = -(2 + y)

c.

x = x - (2 + y)

d.

x = x - 2 + y

e.

None of the above

Which of the following data values is best represented with a floating point variable?

a.

The speed of a snail.

b.

None of the other options

c.

The number of children in a classroom.

d.

The number of acorns in a tree.

e.

The number of pets in a house.

In: Computer Science

The program runs but the math is not correct ( output for amount ) #include <iostream>...

The program runs but the math is not correct ( output for amount )

#include <iostream>

using namespace std;
int main()
{

int hoursParked;
double total;
double Car = 2.50 ;
double Truck = 5.50;
double Bus = 19.00;
double rateC = 1.50;
double rateT = 3.75;
double rateB = 6.75;
char type;


cout << "Please Enter number of hours parked and the type of car (Type: (C)ar or (T)ruck or (B)us): " << endl;
cin >> type >> hoursParked;


switch (type)
{
case 'C':
case 'c':
{
if (hoursParked <= 2.00)
total = 2 * 1.25;
else
total = (( hoursParked - 2.00 )* rateC)+ Car ;
}
case 'T':
case 't':
{
if (hoursParked <= 2.00)
total = Truck;
else
total = ((hoursParked - 2.00) * rateT) + Truck;
break;
}
case 'B':
case 'b':
{
  
if (hoursParked <= 2.00)
total = Bus;
else
total = ((hoursParked - 2.00)*rateB) + Bus;
break;
}
}
cout << "Vehicle type: ";
if(type == 'C')
cout << "Car" << endl;
else if(type == 'T')
cout << "Truck" << endl;
else
cout << "Bus" << endl;
cout << "Time:" << hoursParked << endl;
cout << "Amount Due:$" << total <<endl;

return 0;
}

In: Computer Science

. In this lab you will be making a text-based calendar program that looks like: JANUARY...

. In this lab you will be making a text-based calendar program that looks like:
JANUARY 2018
S M Tu W Th F S
1 2 3 4 5 6   
7 8 9 10 11 12 13
14 15 16 17 18 19 20   
21 22 23 24 25 26 27
28 29 30 31
Your calendar should be able to print months in the future and in the past.
Activity #1
In C++ create a calendar program that has the following two functions:
▪ printMonth – this function has two parameters (month, year) and will print out the calendar for the specified month in the format discussed in the introduction to this lab.
▪ printYear – this function has one parameter (year) and will print out the calendar for all 12 months in that year.
In addition to the above functions you should also create a main function that will test your program. In the main function the program should ask the user if he/she wants a year or month calendar. If the user wants a year calendar the program should input the year. If the user wants a month calendar the program should input the month and year.
In order to print the calendar for a given month you need to write an algorithm to determine which day of the week the first day of the month is on. You can determine this using the following information:
1. Number of days in each month.
a. January – 31 days
b. February – 28 or 29 days
c. March – 31 days
d. April – 30 days
e. May – 31 days
f. June – 30 days
g. July – 31 days
h. August – 31 days
i. September – 30 days
j. October – 31 days
k. November – 30 days
l. December – 31 days
2. Leap years.
In a leap year February has an extra day, which is why February can be either 28 or 29 days long. Years that are evenly divisible by 4 are leap years except when the year is also evenly divisible by 100. There is also an exception to this rule since years that are evenly divisible by 100 but also evenly divisible by 400 are considered leap years. For example:
• 2009 is not a leap year because it is not evenly divisible by 4.
• 2008 was a leap year because it was evenly divisible by 4 and not evenly divisible by 100.
• 1900 was not a leap year because even though it was evenly divisible by 4 it was also evenly divisible by 100 (and not evenly divisible by 400).
• 2000 was a leap year because it is evenly divisible by 4, evenly divisible by 100 and evenly divisible by 400.

In: Computer Science

Using the provided m1_mbox.txt, write a program that reads the data from the file, locates the...

Using the provided m1_mbox.txt, write a program that reads the data from the file, locates the lines containing sender information (those lines begin with 'From:'), and extracts just the email address of the sender of each message. It should then duplicate the set of email addresses for senders, and write the duplicated list to a file called senders.txt, so that each sender appears in the output file only once. In addition, your program should print to the screen the following stats: total number of email messages in the file, and number of unique senders. Your program should expect the input and output files to be in the same directory and you should hardcode this into your program (that is, do not use command line arguments).

In: Computer Science

State the data cube computation methods. Give example for each method

State the data cube computation methods. Give example for each method

In: Computer Science

java: create a conplete class named patient. the patient class shouls include teo private instance variables...

java: create a conplete class named patient. the patient class shouls include teo private instance variables named PatientID of type int lastName of type string. include all the parts of a well-formed class described. set the instance variable defaults to appropriate values.

In: Computer Science

In Python Which initial value of x will make the following piece of code leave a...

In Python

Which initial value of x will make the following piece of code leave a 9 in the final value of x?

x = ____?
if x < 7:
   x = x + 1
x = x + 2

a.

11

b.

9

c.

7

d.

None of the above

Which initial value of x will make the following piece of code leave a 20 in the final value of x?
x = ____?
if x * 2 <= 34:
   x = 0
else:
   x = x + 1

x = x + 1

a.

17

b.

18

c.

19

d.

20

e.

None of the above

What is a common word for the textual representation of a program?

a.

code

b.

prompt

c.

interpreter

d.

expression

e.

None of the above

Which statement reads a user-entered string into variable user_name?

a.

input = user_name()

b.

user_name = input()

c.

input() => user_name

d.

user_name = "input()"

e.

None of the above

What is the output?

count = 0
while count < 3:
     print('loop')
count = count + 1
print('final value of count:', count)

a.

Prints 'loop' once, then 'final value of count: 1'

b.

Prints 'loop' three times, then 'final value of count: 3'

c.

Prints 'loop' three times, then 'final value of count: 4'

d.

Prints 'loop' forever (infinite loop)

e.

None of the above

In: Computer Science

Please Why do we need a dynamic stack? How to implement a dynamic array stack?(JAVA)

Please

Why do we need a dynamic stack? How to implement a dynamic array stack?(JAVA)

In: Computer Science

In Python Dividing by zero is an example of which type of error? a. runtime b....

In Python

Dividing by zero is an example of which type of error?

a.

runtime

b.

syntax

c.

logic

d.

None of the previous

In the statement:age = input('Enter your age: '), the string 'Enter your age: ' is called a(n) _____.

a.

prompt

b.

prefix

c.

variable

d.

assignment

e.

None of the above

Fill in the blank so that the loop displays all odd numbers from 1 to 100.

i = 1
while i <= 100:
    print(i)
    i = _____

a.

1

b.

i + 1

c.

2

d.

i + 2

e.

None of the above

How many times does the following loop iterate?

i = 5
while i < 10:
    print(i)
    i = i + 1

a.

0

b.

4

c.

5

d.

6

e.

None of the above

In: Computer Science

Using the data structure concept of topological ordering,demonstrate using pseudocode how you can implement an operation...

Using the data structure concept of topological ordering,demonstrate using pseudocode how you can implement an operation to schedule picking during a delivery process in a warehouse.

In: Computer Science