9. #include
<fstream>
#include <iostream>
using namespace std;
int main()
{
float bmi;
ifstream inFile;
inFile.open("bmi.txt");
while (!inFile.eof())
{
inFile >>
bmi;
if( bmi <
18.5)
{
cout << bmi << " is underweight " ;
}
else if( bmi >= 18.5
&& bmi <= 24.9)
{
cout << bmi << " is in normal range " ;
}
else if( bmi >= 25.0
&& bmi <= 29.9)
{
cout << bmi << " is overweight " ;
}
else if( bmi >=
30)
{
cout << bmi << " is obese " ;
}
cout <<
endl;
}
return 0;
}
bmi.txt looks like below:
25.0
17.3
23.1
37.0
What will be the output when the above code runs with the above bmi.txt file.
In: Computer Science
Sketch! This assignment is to write a Python program that makes use of the OpenGL graphics library to make an interactive sketching program that will allow the user to do line drawings. The user should be able to choose from a palette of colors displayed on the screen. When the user clicks the mouse in the color palette area, the drawing tool will switch to using the color selected, much like dipping a paint brush into a new color of paint.
Here are two starter codes. I'm trying to combine them basically but end up with a mess. It's supposed to be mimicking Microsoft Paint. Pick a color and then draw a line with it. There are 3 boxes on the left side, red, green, and blue. When the user clicks the box the line color matches the color of the box. Then the user can click in the space and free draw a line of that color, similar to Microsoft paint.
from OpenGL.GL import *
from OpenGL.GLUT import *
from OpenGL.GLU import *
# global variables
width = 400 # window dimensions
height = 300
menuwidth = 100 # menu dimensions
ncolors = 3 # number of colors
boxheight = height//ncolors # height of each color box
colormenu = [[1.0,0.0,0.0], [0.0,1.0,0.0], [0.0,0.0,1.0]]
menuindex = -1
###
# Returns true if point (x, y) is in the color menu
###
def incolormenu(x, y):
return x >= 0 and x <= menuwidth and y >= 0 and y <= height
###
# Returns index of point (x, y) in the color menu
###
def colormenuindex(x, y):
if not incolormenu(x, y):
return -1;
else:
return y//boxheight
###
# Watch mouse button presses and handle them
###
def handleButton(button, state, x, y):
global menuindex
y = height - y # reverse y, so zero at bottom, and max at top
if button != GLUT_LEFT_BUTTON: # ignore all but left button
return
# if button pressed and released in same menu box, then update
# the color of the large square
if state == GLUT_DOWN:
if incolormenu(x, y):
menuindex = colormenuindex(x, y)
else:
if incolormenu(x, y) and colormenuindex(x, y) == menuindex:
glColor3f(colormenu[menuindex][0], colormenu[menuindex][1], colormenu[menuindex][2])
glRecti(menuwidth, 0, width, height)
glFlush()
###
# Draw the colored box and the color menu
###
def drawMenu():
# clear window
glClear(GL_COLOR_BUFFER_BIT)
# draw the color menu
for i in range(ncolors):
glColor3f(colormenu[i][0], colormenu[i][1], colormenu[i][2])
glRecti(1, boxheight * i + 1, menuwidth - 1, boxheight * (i + 1) - 1)
glFlush()
###
# Main program
###
def main():
glutInit()
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGBA)
glutInitWindowSize(width, height)
window = glutCreateWindow("Color Menu")
# callback routine
glutDisplayFunc(drawMenu)
glutMouseFunc(handleButton)
# lower left of window is (0, 0), upper right is (width, height)
gluOrtho2D(0, width, 0, height)
# specify window clear (background) color to be black
glClearColor(0, 0, 0, 0)
glutMainLoop()
if __name__ == "__main__":
main()
from OpenGL.GL import *
from OpenGL.GLUT import *
from OpenGL.GLU import *
# global variables
width = 600 # window dimensions
height = 600
wleft = 0
wright = width
wbottom = 0
wtop = height
tracking = False
###
# Returns true if point (x, y) is in the window
###
def inwindow(x, y):
return x > wleft and x < wright and y > wbottom and y < wtop
###
# Draw a line to new mouse position
###
def m_Motion(x, y):
y = wtop - y
if tracking and inwindow(x, y):
glBegin(GL_LINES)
glVertex2i(width//2, height//2)
glVertex2i(x, y)
glEnd()
glFlush()
###
# Watch mouse button presses and handle them
###
def handleButton(button, state, x, y):
global tracking
y = wtop - y
if button != GLUT_LEFT_BUTTON:
return
if state == GLUT_DOWN:
if inwindow(x, y):
tracking = True
else:
tracking = False
###
# Clear the window
###
def drawMouse():
glClear(GL_COLOR_BUFFER_BIT) # clear the window
glColor3f(0, 0, 0) # set mouse line color
glFlush()
###
# Main program
###
def main():
glutInit()
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGBA)
glutInitWindowSize(width, height)
window = glutCreateWindow("Mouse Exam")
# callback routine
glutDisplayFunc(drawMouse)
glutMouseFunc(handleButton)
glutMotionFunc(m_Motion)
# lower left of window is (0, 0), upper right is (width, height)
gluOrtho2D(0, width, 0, height)
# specify window clear (background) color to be dark grey
glClearColor(0.7, 0.7, 0.7, 1)
glutMainLoop()
if __name__ == "__main__":
main()
In: Computer Science
//Write in C++
//use this evote code and add File I/O operations (as specified in the comments) to it.
#include<iostream>
using namespace std;
int main()
{int choice;
int bezos = 0 , gates = 0 , bugs = 0 ;
int vc = 0 ;
do {
cout<<"\n\n\nEVOTE\n-----"
<<"\n1.Jeff Bezos
<<"\n2.Bill Gates
<<"\n3.Bugs Bunny"
// 4. Print current tally [hidden admin option]
// 5. Print audit trail [hidden admin option]
// 6. mess with the vote [hidden hacker option] E.C.
// 7. END THE ELECTION
<<"\n\n Your selection? ";
cin >> choice ;
if(choice==1) {bezos++ ; vc++ ; cout<<"\nThanks for voting!"; }
if(choice==2) {gates++ ;vc++ ; cout<<"\nThanks for voting!"; }
if(choice==3) { bugs++ ; vc++ ; cout<<"\nThanks for voting!"; }
if((choice<1)||(choice>7))cout<<"\nPlease enter 1-3";
// write what happened to FILES
// Tally.txt (overwrite) bezos x gates x bugs x
// auditTrail.txt ios::app (everything typed) 1 2 3 3 56 -12 4
} while(choice != 7 ) ;
cout<<"\n\nRESULTS:\n--------"
<<"\nTotal Votes Cast This Election: "<< vc
<<"\nJeff Bezos: "<< bezos
<<"\nBill Gates: "<< gates
<<"\nBugs Bunny: "<<bugs;
cout<<"\n\n";
system("pause"); // leave this out if using newer DEV C++
return 0;
}
In: Computer Science
A) DDL
For Company DB Schema, Answer the below questions:
Emp (Empno, Ename, Job, Hiredate, Sal, Comm, Deptno)
Dept (Deptno, Dname, loc)
1. Retrieve the data of all employees.
2. Retrieve the data of all Salemanemployees.
3. Retrieve the name and Salary of all employees.
4. Retrieve the name and salary of Salemanemployees.
5. Retrieve the name and salary of all employees with Salary more than 2000.
6. Retrieve the Name and Salary of all employees who work in department no 20.
7. Retrieve the name and Job of all employees with Salary more than 2000 and hiredate after 01-01-1981.
8. Retrieve the Job and Salary of all employees with Name = FORD or MARTIN.
9. Retrieve the Name and Number of all Departments.
10. Retrieve the Employee Name and Department number for all employees.
11. Retrieve the Employee Name and Department name for all employees.
12. Retrieve the Employee Name and who works in Department name = RESEARCH.
13. Retrieve the Employee names who workin one of these Departments: RESEARCHand SALES.
14. Retrieve the Employee name who works in department located in NEW YORK.
please write in computer word not on paper
In: Computer Science
Urgent need: please solve this question below:
A description of how your chosen Information Systems Technology is currently being used in different areas of business, government or and/or society. If your technology is being used in many different areas, try and focus on four areas that either have a high impact or that interest your group. Be sure to include the impacts that the technology is having on each of these areas. Your impacts should include both quantitative (e.g., financial, etc.) as well as qualitative (e.g., quality of life, etc.) ones. In addition, describe 3-4 advantages and 3-4 disadvantages of the use of the technology in these areas. For the advantages, you should clearly describe how/why these are advantages, whether or not they are sustainable and why. For the disadvantages, you should clearly describe why they are disadvantages, how serious these disadvantages are and whether or not there are any ways to overcome these disadvantages.
In: Computer Science
Define an interface called Vehicle, which requires the following methods getName: returns a String getTopSpeed: returns an int getMaxPassengers: returns an int Note that the class Car implements this interface and is preloaded (in one of the following questions you will define this class)
For example:
Test
Vehicle v = new Car("BMW", 280, 5); System.out.println(v.getName()); System.out.println(v.getTopSpeed()); System.out.println(v.getMaxPassengers());
Results :
BMW
280
5
Test 2 :
Vehicle v = new Car("Smart", 150, 2); System.out.println(v.getName()); System.out.println(v.getTopSpeed()); System.out.println(v.getMaxPassengers());
Results :
Smart
150
2
In: Computer Science
Question 3 a) What kind of leadership style would you like to apply as a project manager to lead your team? AN b) With a typical case study example, show how you would go about your project scope management. AP c) In your own view, how can scope creep affect project success?
In: Computer Science
Create a GUI matlab code that computes for the position, velocity, and acceleration of the equation and displays their respective graph.
In: Computer Science
What are three different types of SIEM's on the market today? Security information and event management (SIEM) is a subsection within the field of computer security, where software products and services combine security information management (SIM) and security event management (SEM). They provide real-time analysis of security alerts generated by applications and network hardware.
In: Computer Science
Extract errors from the following codes & then obtain
weather they are Syntax
Error or Run Time Error? [15 pts]
a) [2 pts]
1 Dim number1 As Integer
2 Dim number2 As Integer
3 Dim result As Integer
4
5 number1 = (4 * 6 ^ 4) / (10 Mod 4 – 2)
6 number2 = (16 \ 3) ^ 2 * 6 + 1
7 result = number1 - number2
Line# / Error Description /Error Type (Syntax or Runtime) /Correction
b) [4pts]
1 Dim number1 As Double
2 Dim number2 Double
3 Dim result As Char
4
5 number1 = (4 ^ 2)
6 number2 = (16 \ 2)
7 result = number1 \ number2
Line# /Error Description /Error Type (Syntax or Runtime) /Correction
In: Computer Science
Question 4 a) Why do you think bottom-up approach is useful in gathering inputs for a new project? CR b) How would you go about sequencing activities of your project? AP 3 c) How significant is it to inculcate quality management into projects? CR (Total marks: 25)
In: Computer Science
A random variable (RV), x is distributed with a pdf as follows:
fX(x) = [C × x × (1 – x)] 0 ≤ x ≤ a (C and a are constants)
= 0 otherwise
Hence, determine the following: (i) C; (ii) cumulative probability of x in the range, [(u × a) ≤ x ≤ (v × a)]; where u and v are fractions; (iii) E[x]; (iv) second moment of x ; and, (v) standard deviation of x. Assume: a = 1, u = 0.5 and v = 0.75
Hence, choose the correct set of answers in the multiple-choices listed:
Multiple-choices on the answer-set
|
Choices |
(i) C |
(ii) cdf [ua ≤ x ≤ va] |
(iii) E[x] |
(iv) m2 |
(v) sigma(x) |
|
1 |
1.5 |
0.4458 |
0.75 |
0.35 |
0.250 |
|
2 |
1.6 |
1.3435 |
0.60 |
0.55 |
0.254 |
|
3 |
1.0 |
0.3438 |
0.50 |
0.30 |
0.224 |
|
4 |
1.0 |
0.3466 |
0.51 |
0.32 |
0.124 |
|
5 |
0.8 |
0.1458 |
0.45 |
0.22 |
0.324 |
In: Computer Science
The TOPCAR taxi company is developing a new computer system to be used to support taxi booking and corporate client credit accounts. This computer system aims to automate some manual processes and cut down on labour costs as TOPCAR has many customers from large corporate companies, e.g. CEO, and managers often need taxi trips to the airport. The following describes the activities that must be processed by the computer system:
A client company must first register and open a credit account with TOPCAR at TOPCAR’s website, in which case certain credit checks are made such as checking credit history of client company’s debt level. If the client company has no bad debt history, a credit account for the client company is set up.
At least 24 hours after successful account registration, authorized persons from such client company can request a taxi booking form TOPCAR’s website. When this happens, the availability of a taxi at the requested date and time is checked, as is the credit status of the client company checked. (Note that credit status in finance means a measure of a lender’s willingness to lend money to a particular person or organization, depending on their ability to repay).
If these two checks are successful, a booking is made, and a written confirmation is sent via SMS and emailed to client company. After the customer from the client company has used the taxi, the driver sends in a record of the work, including the cost, and this is added to client company’s account. (Note that driver is an outsourced worker from TOPCAR’s point of view.) At the end of each month, taxi bills are sent via SMS and emailed to client companies for settlement.
From the above description, draw a data flow diagram showing the flow of input information (and/or data) and output information (and/or data) to and from processes and database stores within this computer system and any external environmental elements that interact with this computer system. In this diagram, you must identify the following:
in (a) (5.5 marks)
(Hint: there are two environmental elements that interact with this computer system, and six main processes in this computer system)
In: Computer Science
Suppose as a language designer, you plan to implement a feature called “output-only” parameters. The expected semantics is that all output-only parameters are uninitialized when the callee starts execution; they can be used (both read and write) as other kinds of parameters within the callee; finally, the corresponding actual parameter in the caller is updated to the final values of the “output-only” parameters. Briefly describe one possible implementation of such “output-only” parameters
In: Computer Science
Create an array of ten strings. Write a program to join and split these strings. Feel free to use any whitespace character. Explain how the program works, when to use Python arrays, and when to use tuples, dictionaries, and sets. Explain how the program works and how it can be utilized to support an organization’s requirements.
In: Computer Science