In: Computer Science
Asks the user "How many parrots do you own?"
2: Reads in that many single word names (one for each parrots) from the user and stores the names in an array.
3: After the user has finished entering names, the program should display the list of all the parrots the user entered.
4: then display the parrots in alphabetical order for part 3. Note: string objects can be compared with the “<” operator, which will determine if a given string is alphabetically less than another string.
You may assume the user will own at most 50 parrots.
c++
In: Computer Science
In C++ write an application that calculates total retail values for 5 different shoes entered by the user.
Shoe 1 $15.50
Shoe 2 $27.30
Shoe 3 $34.50
Shoe 4 $42.11
Shoe 5 $54.25
Application must read shoe number and quantity sold for each
transaction stdin, compute the total value of that sale, and add
the value of that sale to a grand total for that shoe. After all
data has been entered, display the total value of each of the five
shoe items. Must have driver and a class, must use a switch
structure to which shoes sales to update, must use a sentinel
controlled loop to determine when the program should stop looping
and display result.
Data members
Product price
Total sales for product(in dollars)
Member Functions
One 1 argument constructor(representing the shoe price), set the
value of the data member using this argument. Getters and setters
for data member, and updateTotalSales method(uses one parameter
representing quantity sold and does not return a value) . must use
getter and setter methods to access the fields do not access them
directly. It computes the total value of the current sale by
multiplying the argument passed by the shoess price. It updates the
shoes total Sales data member by adding the value calculated in the
previous step to the shoes existing totalSales. Must use getter and
setter functions. Do not access the data members directly.
Main function
Instantiate 5 separate objects of the class Shoe, passing the
appropriate argument to each constructor. The Shoe class
constructor requires the price of that instance of the shoe. The
prices can be hard coded numbers.
Using Sentinel controlled loop
1. Read the shoe number and the quantity sold for one
transaction.
2. Use a switch statement to determine which Shoe
objects sales to update.
3. Call the appropriate Shoe objects updateTotalSales
function.
4. Continue loop until user enters 0 for the shoe
number.
5. After the loop is complete display each shoe objects
total sales, including the dollar sign, two decimal places with a
field width of 10.
Sample run
Shoe number: 2
Quantity sold: 4
Shoe number: 1
Quantity sold: 3
Shoe Number: 5
Quantity sold: 2
Shoe number: 1
Quantity sold: 2
Shoe number: 5
Quantity sold: 3
Shoe Number: 4
Quantity sold: 2
Shoe Number: 0
Total Sales
Shoe 1 : $77.50
Shoe 2: $109.20
Shoe 3: $0
Shoe 4: $84.22
Shoe 5: $271.25
In: Computer Science
IN JAVA LANGUAGE
Linked List-Based Stack Implementation
Implement Stack using a Linked List
Instead of using an array, as the StackLab did, here you will use a Linked List from your language's library. Implement all the methods of Stack : push(), pop(), size(), printStackDown(), etc, using calls to the linked list methods that correspond to the actions need. In the array implementation, you wrote code to manipulate the array. For this linked list implementation, methods already exist.
Before the underlying implementation of stack was array, now the underlying implementation of stack will be Linked list.
In: Computer Science
IN JAVA LANGUAGE
Linked List-Based Queue Implementation
Implement Queue using a Linked List.
Instead of using an array, as the QueueLab did, here you will use a Linked List from your language's library. Implement all the methods of Stack : enqueue(), dequeue(), size(), printQueue(), etc, using calls to the linked list methods that correspond to the actions need. In the array implementation, you wrote code to manipulate the array. For this linked list implementation, methods already exist.
Before the underlying implementation of queue was array, now the underlying implementation of queue will be Linked list.
In: Computer Science
7.24 LAB: Triangle area comparison (classes)
Language: C++
Given class Triangle (in files Triangle.h and Triangle.cpp), complete main() to read and set the base and height of triangle1 and of triangle2, determine which triangle's area is larger, and output that triangle's info, making use of Triangle's relevant member functions.
Ex: If the input is:
3.0 4.0 4.0 5.0
where 3.0 is triangle1's base, 4.0 is triangle1's height, 4.0 is triangle2's base, and 5.0 is triangle2's height, the output is:
Triangle with larger area: Base: 4.00 Height: 5.00 Area: 10.00
In: Computer Science
In the C programming language:
Pretend you are an astrophysicist making a report on the
distances to the 50 brightest stars.
You need to print out a nice table sorted by distance to include in
your report.
Using data in input.txt, write a program that can read in the included file input.txt.
Use scanf or fscanf (or any other function you prefer) to read the comma separated values (CSV) into an array of structs representing each record.
Once all records are loaded, sort the list by the distance
field. Alternatively, you can keep the array
sorted by its distance during reading. Use any sorting function you
want.
Save the data sorted by the distance field (lowest to highest)
in another file called "distance.txt".
Save only the following fields in this order:
Distance
Name
Bayer Name
right ascension
declination
Make sure that the columns line up nicely and that the header is printed before the data.
input.txt contains:
Rank,Star Name, Bayer Name, Visual Mag., Abs. Mag., Dist. (ly),
Spectral Type, Lum. (Sol), Mass (Sol), Diam. (Sol), RA (hr_min),
Dec (deg)
1, Sirius, Alp CMa, -1.44, 1.45, 8.6, A1V, 25, 2.0, 1.7, 06h 45m,
-16.7
2, Canopus, Alp Car, -0.62, -5.53, 310, F0Ib, 13600, 8.5, 65, 06h
24m, -52.7
3, Rigil Kent., Alp Cen, -0.28c, 4.34, 4.4, G2V+K1V, 1.5, 1.1, 1.2,
14h 40m, -60.8
4, Arcturus, Alp Boo, -0.05v, -0.31, 36.7, K2III, 170, 1.1, 26, 14h
16m, +19.2
5, Vega, Alp Lyr, 0.03v, 0.58, 25.3, A0V, 37, 2.1, 2.3, 18h 37m,
+38.8
6, Capella, Alp Aur, 0.08v, -0.48, 42.2, G5III+G0II, 79, 2.7, 12,
05h 17m, +46.0
7, Rigel, Bet Ori, 0.18v, -6.69, 770, B8Ia, 66000, 17, 78, 05h 15m,
-8.2
8, Procyon, Alp CMi, 0.40, 2.68, 11.4, F5IV-V, 7.7, 1.5, 2.0, 07h
39m, +5.2
9, Betelgeuse, Alp Ori, 0.45v, -5.14, 430, M2Ib, 105000, 18, 936,
05h 55m, +7.4
10, Achernar, Alp Eri, 0.45v, -2.77, 144, B3V, 3300, 6-8, 10, 01h
38m, -57.2
11, Hadar, Bet Cen, 0.61v, -5.42, 525, B1III, 16000, 10.7, 8, 14h
04m, -60.4
12, Altair, Alp Aql, 0.76v, 2.20, 16.8, A7V, 10.6, 1.8, 1.8, 19h
51m, +8.9
13, Acrux, Alp Cru, 0.77c, -4.19, 320, B0.5IV+B1V, 25000, 14, ?,
12h 27m, -63.1
14, Aldebaran, Alp Tau, 0.87, -0.63, 65.1, K5III, 425, 1.7, 44.2,
04h 36m, +16.5
15, Spica, Alp Vir, 0.98v, -3.55, 260, B1V+B2V, 13400, 11, 7.8, 13h
25m, -11.2
16, Antares, Alp Sco, 1.06v, -5.28, 605, M1Ib+B4V, 65000, 15.5,
800, 16h 29m, -26.4
17, Pollux, Bet Gem, 1.16, 1.09, 33.7, K0III, 32, 1.9, 8, 07h 45m,
+28.0
18, Fomalhaut, Alp PsA, 1.17, 1.74, 25.1, A3V, 17.7, 2.1, 1.8, 22h
58m, -29.6
19, Deneb, Alp Cyg, 1.25v, -8.73, 3200, A2Ia, 54000, 20, 110, 20h
41m, +45.3
20, Mimosa, Bet Cru, 1.25v, -3.92, 350, B0.5III, 34000, 14, 8, 12h
48m, -59.7
21, Regulus, Alp Leo, 1.36, -0.52, 77.5, B7V, 150, 3.5, 3.2, 10h
08m, +12.0
22, Adhara, Eps CMa, 1.50, -4.10, 430, B2II, 20000, 10, ?, 06h 59m,
-29.0
23, Castor, Alp Gem, 1.58c, 0.59, 51.5, A1V+A2V, 30/14, 2.2/1.7,
2.3/1.6, 07h 35m, +31.9
24, Gacrux, Gam Cru, 1.59v, -0.56, 87.9, M3.5III, 1500, 3, 113, 12h
31m, -57.1
25, Shaula, Lam Sco, 1.62v, -5.05, 700, B2IV, ?, 10.4, 6.2, 17h
34m, -37.1
26, Bellatrix, Gam Ori, 1.64, -2.72, 240, B2III, 21500, 8, 5.7, 05h
25m, +6.3
27, Elnath, Bet Tau, 1.65, -1.37, 131, B7III, 70, 4.5, 5.5, 05h
26m, +28.6
28, Miaplacidus, Bet Car, 1.67, -0.99, 111, A2III, 210, 3, 5.7, 09h
13m, -69.7
29, Alnilam, Eps Ori, 1.69v, -6.38, 1300, B0Ia, 375000, 40, 26, 05h
36m, -1.2
30, Alnair, Alp Gru, 1.73, -0.73, 101, B7IV, 380, 4, 3.6, 22h 08m,
-47.0
31, Alnitak, Zet Ori, 1.74c, -5.26, 820, O9.5Ib+B0I, 100000, 28,
20, 05h 41m, -1.9
32, Regor, Gam Vel, 1.75v, -5.31, 840, WC8+O9Ib, 100000, 30, 13,
08h 10m, -47.3
33, Alioth, Eps UMa, 1.76v, -0.21, 80.9, A0IV, 108, 3, 3.7, 12h
54m, +56.0
34, Kaus Aust., Eps Sgr, 1.79, -1.44, 145, B9.5III, 375, 5, 7, 18h
24m, -34.4
35, Mirfak, Alp Per, 1.79, -4.50, 590, F5Ib, 5400, 11, 56, 03h 24m,
+49.9
36, Dubhe, Alp UMa, 1.81, -1.08, 124, K0III+F0V, 300, 4, 30, 11h
04m, +61.8
37, Wezen, Del CMa, 1.83, -6.87, 1800, F8Ia, 50000, 17, 200, 07h
08m, -26.4
38, Alkaid, Eta UMa, 1.85, -0.60, 101, B3V, 700, 6, 1.8, 13h 48m,
+49.3
39, Sargas, The Sco, 1.86c, -2.75, 270, F1II, 960, 3.7, 20, 17h
37m, -43.0
40, Avior, Eps Car, 1.86v, -4.58, 630, K3II+B2V, 6/11 K, 4.6/16,
153/6, 08h 23m, -59.5
41, Menkalinan, Bet Aur, 1.90v, -0.10, 82.1, A2IV, 48, 2.4, 2.8,
06h 00m, +44.9
42, Atria, Alp TrA, 1.91, -3.62, 415, K2Ib-II, 5500, 7, ?, 16h 49m,
-69.0
43, Koo She, Del Vel, 1.93, -0.01, 79.7, A0V, ?, ?, ?, 08h 45m,
-54.7
44, Alhena, Gam_Gem, 1.93, -0.60, 105, A0IV, 160, 2.8, 4.4, 06h
38m, +16.4
45, Peacock, Alp Pav, 1.94, -1.81, 180, B0.5V+B2V, 2100, 5, 4.4,
20h 26m, -56.7
46, Polaris, Alp UMi, 1.97v, -3.64, 430, F7Ib-II, 2200, 7.5, 30,
02h 32m, +89.3
47, Mirzam, Bet CMa, 1.98v, -3.95, 500, B1III, 19000, ?, ?, 06h
23m, -18.0
48, Alphard, Alp Hya, 1.99, -1.69, 180, K3II, ?, 3.0, 50.5, 09h
28m, -8.7
49, Algieba, Gam Leo, 2.01, -0.92, 126, K0III+G7II, 320/50, 1.23,
32, 10h 20m, +19.8
50, Hamal, Alp Ari, 2.01, 0.48, 65.9, K2III, 90, 2, 15, 02h 07m,
+23.5
In: Computer Science
7.28 LAB: Artwork label (classes/constructors). Written in C++
Given main(), complete the Artist class (in files Artist.h and Artist.cpp) with constructors to initialize an artist's information, get member functions, and a PrintInfo() member function. The default constructor should initialize the artist's name to "None" and the years of birth and death to 0. PrintInfo() should display Artist Name, born XXXX if the year of death is -1 or Artist Name (XXXX-YYYY) otherwise.
Complete the Artwork class (in files Artwork.h and Artwork.cpp) with constructors to initialize an artwork's information, get member functions, and a PrintInfo() member function. The constructor should by default initialize the title to "None", the year created to 0. Declare a private field of type Artist in the Artwork class.
Ex. If the input is:
Pablo Picasso 1881 1973 Three Musicians 1921
the output is:
Artist: Pablo Picasso (1881-1973) Title: Three Musicians, 1921
If the input is:
Brice Marden 1938 -1 Distant Muses 2000
the output is:
Artist: Brice Marden, born 1938 Title: Distant Muses, 2000
In: Computer Science
Design a GUI application for the Bank Account assignment you did in the File IO module.
It can be simple as a single user app with three buttons - checkBalance, Withdraw, Deposit - textbox for entering the amount.
On Click of buttons, you can show the current balance in a dialog box.
If you have more interest, you can expand it further according to your design of the application
In python
Please show codes and output.
The calculator must be in a standard size not too small not to big
In: Computer Science
*Not in C++ Language! Pleaseeee in Java?!!*
Programming Exercise 3.20 required you to design a PID
manager that allocated a unique process
identifier to each process. Exercise 4.20 required you to modify
your solution to Exercise 3.20 by writing
a program that created a number of threads that requested and
released process identifiers. Now
modify your solution to Exercise 4.20 by ensuring that the data
structure used to represent the
availability of process identifiers is safe from race conditions.
Use Pthreads mutex locks.
if there is any questions, leave a comment. Thank you.
In: Computer Science
We are going to create our own implementation of the game “FloodIt”. Several versions of this game can be found, for example a version for android, on which this description is based, here. Several Web versions are available
In this game, a square board is filled with dots, each having one of six possible colours. The players initially “captures” the top left dot. The player keeps choosing one of the six colours. Each time a colour is chosen, the dots that have already been captured turn into that colour. Each dot that is a neighbour1 of a captured dot, and whose colour matches the newly selected colour becomes itself captured. The game ends once the entire board is captured (the board is “flooded” because all the dots have the same colour). As the game can only progress (a captured dot cannot be lost), the issue of the game is certain. The goal is thus to flood the board in as few steps as possible.
https://drive.google.com/file/d/0B4hEHn5tHkyxYzktNUYxbUt4Qkk/view?usp=sharing
In: Computer Science
Prepare a class and tester that simulates and tabulates the result of repeatedly throwing two dice. Recall a dice, a six-sided cube with 1 through 6 dots on each side.
Using a now familiar looping user experience, the user enters the number of throws. Then, the system simulates the throws and displays the results using a frequency distribution chart. For instance:
Please, use this statement to get the dice action started!
String[] labels = {"Snake Eyes", "Ace Deuce", "Hard Four", "Fever Five", "Easy Six", "Natural Seven", "Easy Eight", "Nina", "Easy Ten", " Yo-leven", "Boxcars"};
In: Computer Science
In: Computer Science
Write Python code that checks if an existing variable letter is a lowercase vowel. If it is a, e, i, o, or u and print out "Yes, it is a lowercase vowel". If the letter is y, print out "The letter is a consonant". If the letter is anything else, print out "No, the letter is not a vowel".
(language python)
In: Computer Science
Write a python program that will ask the user to enter as many positive and negative numbers and this process will only stop when the last number entered is -999. Use a while loop for this purpose. Your program should compute three sums; the sum of all numbers, sum of all positive numbers, and the sum of all negative numbers and display them. It should also display the count of all numbers, count of all positive numbers, and count of all negative numbers. Finally, it should compute and display the average of all numbers, average of all positive numbers, and average of all negative numbers.
In: Computer Science