Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Scientific Programming Homework Assignment 2 Program Design and Coding due Febru

ID: 3666480 • Letter: S

Question

Scientific Programming

Homework Assignment 2    Program Design and Coding

due February 10

Grading: 1 point for test data; 3 points for program

this may be a group assignment …no more than 3 programmers to a group.

Using your design form HW 1 choose either of these two problems and

create at least 3 sets of test data for the program…(see below for examples)

You need to also know what the correct answer should be for the data.

            "desk check" your design using the test data you have created

                        see page 2 for some helpful websites about desk checking

            code the program in C++,

            run the program using the test data you have created.

submit test data, source code and copy of the output window

            put these together (copy/paste) in one word document and upload

            if done by a group, only one member uploads the others simply type a                       message in the box stating who they are working with. The uploaded                         document should have all names attached

1. At the football stadium there are three seating categories. Class A seats cost $135. type B seats cost $75. and type C seats cost $45.

     Design a program that asks: how many tickets for each type of seat were sold and then displays the amount of income generated from ticket sales. Show the amount for each type of seat and the total amount.

     test data:

         250     (for class A)

         322     (for class B)

         375     (for class C)

     Correct answer:    type A seats generate   33750

                                      type B seats generate 24150

                                      type C seats generate 16875

                                    total amount                 74775

2. Design a program that calculaes the average rainfall for three months. design a program that asks the user to input the name of each month and the amount of rain that fell each month and display a message similar to this:

     The average rainfall for February, March and April is 5.23 inches

     test data:

            March 1.5

            April    4.2

            May      1.7

      expected output: The average rainfall for March, April, May is 2.46 inches

Use these websites and videos to help you understand more about desk checking

https://www.youtube.com/watch?v=B7-O_U4YYuI

https://www.youtube.com/watch?v=KpbvuAJG_xc

http://ironbark.xtelco.com.au/subjects/PE/PEWeb/lectures/lecture05.html

https://sites.google.com/a/campioncollege.com/it_eveningschoool/problem-solving-and-programming/desk-check-guide

Explanation / Answer

Answer 1-

#include <iostream>
using namespace std;

int main()
{
int a,b,c,tot;
cout<<" No. of Class A tickets sold :";
cin>>a;
cout<<" No. of Class B tickets sold :";
cin>>b;
cout<<" No. of Class C tickets sold :";
cin>>c;
cout<<" Class A tickets genrated sales : $"<<a*135;
cout<<" Class B tickets genrated sales : $"<<b*75;
cout<<" Class C tickets genrated sales : $"<<c*45;
tot=a*135+b*75+c*45;
cout<<" Total sales : $"<<tot;
return 0;
}

Answer 2-

#include <iostream>
#include<iomanip>
using namespace std;

int main()
{
float amount[3],tot=0.0,avg;
char name[3][10];
for(int i=0;i<3;i++)
{
cout<<" Enter month Name : ";
cin>>name[i];
cout<<" Amount of rainfall : ";
cin>>amount[i];
}
for(int i=0;i<3;i++)
{
tot=tot+amount[i];
}
avg=tot/3;
cout<<" The average rainfall for ";
for(int i=0;i<3;i++)
{
cout<<name[i]<<", ";
}
cout<<"is "<<fixed<<setprecision(2)<<avg;
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote