I need to take the code i already have and change it to have at least one function in it. it has to include one function and one loop. I already have the loop but cant figure out how to add a function. I thought i could create a funciton to call to the totalCost but not sure how to do it. Help please.
#include
#include
//main function
int main(void)
{
char userName [20];
char yesOrNo [10];
float cookieCost=0;
float totalCost=0;
float cookiePrice;
//declerations
int cookieAmount;
int cookieChoice;
printf("Welcome to Candy Land Cafe!\n Please tell me
your name.\n");
scanf("%s", &userName);
while(1)
{
printf("%s, what type of cookie
would you like?\n", userName);
printf("1 for Sugar Cookie - $0.25\n2 for Chocolate
Chip - $0.35\n3 for Peanut Butter - $0.35\n");
//input cookie choice
scanf("%d", &cookieChoice);
if(cookieChoice == 1){
//user selected sugar cookie
printf("You selected a Sugar
Cookie. How many cookies would you like?\n");
scanf("%d", &cookieAmount);
//input
cookiePrice = 0.25;
//set cookie price
}
else if (cookieChoice == 2)
{ //user picked chocolate cookie
printf("You selected a Chocolate
Chip Cookie. How many would you like?\n");
scanf("%d", &cookieAmount);
//input
cookiePrice = 0.35;
//set cookie price
}
else if (cookieChoice == 3)
{ //user picked peanut cookie
printf("You selected a Peanut
Butter Cookie. How many would you like?\n");
scanf("%d", &cookieAmount);
//input
cookiePrice = 0.35;
//set cookie price
}
else
{
//did not make valid choice
printf("Invalid Choice, try
again...\n");
continue;
}
//calculate cost of cookies
cookieCost= cookieAmount * cookiePrice;
//add to total cost
totalCost= totalCost + cookieCost;
//cost of current cookie request
printf("%s, your cost is $%.2f.\n", userName,
cookieCost);
//ask for more cookies
printf("Would you like to order another cookie
type?\n");
scanf("%s", yesOrNo);
if(strcmp(yesOrNo, "no")==0) //if no, skip
to total cost and end
{
printf("%s, your total cost is
%.2f\n", userName, totalCost);
break; //end
}
}
//dispaly to user at end "Thanks"
printf("Thanks for ordering from Candy Land Cafe!\n");
system ("pause"); //hold window open
return 0; //success
} //end main
In: Computer Science
Write a Bottle class. The Bottle will have one private int that represents the countable value in the Bottle. Please use one of these names: cookies, marbles, M&Ms, pennies, nickels, dimes or pebbles. The class has these 14 methods: read()(please use a while loop to prompt for an acceptable value), set(int), set(Bottle), get(), (returns the value stored in Bottle), add(Bottle), subtract(Bottle), multiply(Bottle), divide(Bottle), add(int), subtract(int), multiply(int), divide(int), equals(Bottle), and toString()(toString() method will be given in class). All add, subtract, multiply and divide methods return a Bottle. This means the demo code b2 = b3.add(b1) brings into the add method a Bottle b1 which is added to b3. Bottle b3 is the this Bottle. The returned bottle is a new bottle containing the sum of b1 and b3. The value of b3 (the this bottle) is not changed. Your Bottle class must guarantee bottles always have a positive value and never exceed a maximum number chosen by you. These numbers are declared as constants of the class. Use the names MIN and MAX. The read() method should guarantee a value that does not violate the MIN or MAX value. Use a while loop in the read method to prompt for a new value if necessary. Each method with a parameter must be examined to determine if the upper or lower bound could be violated. In the case of the add method with a Bottle parameter your code must test for violating the maximum value. It is impossible for this add method to violate the minimum value of zero. The method subtract with a Bottle parameter must test for a violation of the minimum zero value but should not test for exceeding the maximum value. In the case of a parameter that is an integer, all methods must be examined to guarantee a value that does not violate the MIN or MAX values. Consider each method carefully and test only the conditions that could be violated. (2 point) Further in the semester we will use a runtime exception class to guarantee these invariants. public String toString(){return “” + this.pennies;}
I also have a demo to go with this one...
import java.util.Scanner; // test driver for the Bottle class public class BottleDemo3 { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int x; Bottle bottle1 = new Bottle(); Bottle bottle2 = new Bottle(); Bottle bottle3 = new Bottle(); Bottle bottle4 = new Bottle(); Bottle bottle5 = new Bottle(); System.out.println("please enter a number for bottle1:"); bottle1.read(); System.out.println("Bottle1 is this value " + bottle1 + "."); System.out.println("Please enter a number for bottle2:"); bottle2.read(); bottle3 = bottle2.add(bottle1); System.out.println("The sum of bottle2 and bottle1 is: " + bottle3 + "."); bottle4 = bottle3.divide(2); System.out.println("The 2 bottle average is: " + bottle4 + "."); System.out.print("Subtracting bottle1 from bottle2 is: " ); bottle3 = bottle2.subtract(bottle1); System.out.println( bottle3); bottle3 = bottle2.divide(bottle1); System.out.println("Dividing bottle2 with bottle1 is: " + bottle3 + "."); if (bottle1.equals(bottle2)) { System.out.println("Bottle1 and bottle2 are equal."); } else { System.out.println("Bottle1 and bottle2 are not equal."); } System.out.println("Bottle4 is now given the value of 10 with the set() method."); bottle4.set(10); System.out.println("The value of bottle4 is " + bottle4 + "."); System.out.println("Bottle4 is now multipled with bottle1. The value is placed in " + "bottle5."); bottle5 = bottle1.multiply(bottle4); System.out.println("The value of bottle5 is " + bottle5 + "."); System.out.println("Enter an integer to add to the value bottle1 has."); System.out.println("The sum will be put in bottle3."); x = scan.nextInt(); bottle3 = bottle1.add(x); System.out.println("Adding your number " + x + " to bottle1 gives a new Bottle with " + bottle3 + " in it."); System.out.print("Adding the number " + bottle2 + " which is the number" + " in bottle2 to the\nnumber in "); bottle2 = bottle1.add(bottle2); System.out.println("bottle1 which is " + bottle1 +" gives " + bottle2 + "."); bottle2.set(bottle2.get()); } }
In: Computer Science
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>All Pets Veterinary Hospital</title>
<style>
body {
font-family: arial, sans-serif;
font-size: 100%;
}
/* outer container */
#wrapper {
width: 960px;
margin: 50px auto;
padding: 0px;
background-color: rgb(255, 255, 255);
/* white */
border: 1px solid #000;
/* black */
}
header h1 {
text-align: center;
}
nav {
text-align: center;
background: rgb(175, 196, 206);
}
address figure {
text-align: center;
}
</style>
</head>
<body>
<div id="wrapper">
<!-- outer container -->
<header>
<h1>
All Pets Veterinary Hospital
<br>
<img src="images/logo.jpg" alt="All Pets Veterinary Hospital
logo">
</h1>
<p>
<strong>All Pets Veterinary Hospital</strong> has been
a leader in specialty veterinary care since 1990, fulfilling the
need for specialty healthcare and emergency services for animals in
San Diego County and Southern California.
</p>
<blockquote>
No matter how little money and how few possessions you own, having
a dog makes you rich.
<br> -- Louis Sabin
</blockquote>
</header>
<nav>
<a href="#">Home</a> |
<a href="#">Services</a> |
<a href="#">Staff</a> |
<a href="#">Contact</a>
</nav>
<section>
<h2>About Us</h2>
<figure>
<img src="images/photo_about_us.jpg" alt="Photo of staff and
dog">
</figure>
<p>
All Pets Veterinary Specialty Hospital is proud to provide the
highest quality of specialty care to pets, and the best customer
service to owners in the San Diego community. We have
state-of-the-art facilities, with some of the most advanced
equipment for pets found anywhere in the country. Simply put, we
are committed to being leaders in providing the best specialty care
for your pets.
</p>
</section>
<section>
<h2>Comprehensive Services</h2>
<figure>
<img src="images/photo_comprehensive_services.jpg" alt="Photo of
Dog being examined">
</figure>
<p>
Our hospital utilizes the latest equipment, including MRI, CAT
scan, radiation therapy, digital radiography, a state-of-the-art
intensive care unit, ultra-modern surgical suites, endoscopy,
ultrasound, and much more to provide comprehensive specialty care
for pets of all ages. Furthermore, our staff of doctors,
technicians and client service representatives has exceptional
training, motivation, and compassion for the pets we treat.
</p>
</section>
<section>
<h2>Compassionate Care</h2>
<figure>
<img src="images/photo_compassionate_care.jpg" alt="Photo of
staff and dog">
</figure>
<p>
In summary, as part of our mission to offer high-quality specialty
care for pets in the San Diego area, our hospitals boast a level of
sophistication that can only be found in the most advanced human
medical facilities. We strive for exceptional client service and
compassionate care for patients. Since most of us have pets of our
own, we understand the strong bond that our clients have with their
pets, and realize that they are part of the family.
</p>
</section>
<aside>
<h2>Testimonials</h2>
<p>
<q>Since I adopted my dogs they both have had significant
health issues. In search of a vet that we like we tried several vet
offices in San Diego. I was really impressed by this facility. Not
only they have very reasonable prices, but they love animals, and
they care a lot about all their patients. Unlike some other offices
we have been to, they never prescribe any unnecessary treatments
and they are always very clear about what treatment options we have
for our budget. If something serious is going on they follow up
with us after the visit, and just truly care about well being of
our animals.</q>
<br> - J. Smith
</p>
<p>
<q>Recently one of my dogs passed away. Me and my husband are
so heartbroken. The staff has been so compassionate and caring
through this difficult time. We could not ask for a better doctors
for our fur-babies! I highly recommend this veterinary hospital
office for anyone looking for a new or better veterinary clinic for
their pets. They treat and take good care of my dogs like they are
one of their own furry family members!</q>
<br> - A. Lopez
</p>
</aside>
<footer>
<h2>Contact us</h2>
<p>
If you're looking for high-quality specialty care for your pets,
call us at <strong>(858) 777-7700</strong> or you can
schedule an appointment for your pet online.
</p>
<address>
We are located at:<br>
10400 Sorrento Valley Road<br>
San Diego, CA 92121<br>
<strong>(858) 777-7700</strong>
<figure>
<img src="images/icons_social.jpg" alt="social icons">
</figure>
</address>
</footer>
</div>
<!-- end outer container -->
</body>
</html>
1.Add the needed CSS property, using the selectors of your choice so that the text is not so close to the edge of the outer border of the main “wrapper”. You want to adjust the space inside the element.
2.Add the needed CSS property, using the selector(s) of your choice so that the <section> <aside> and <footer>
elements are not so close to each other from the top/bottom. You want to adjust the space outside the element.
3.Add the needed CSS property, using the selector(s) of your choice to create a visual separator effect along the bottom of the <section> and <aside>
elements – do not use an element. This is done using the border property! Use any style of your choice
4. Add the needed CSS property or properties, using the selector(s) of your choice to apply at least a shadow to the three photos. You may add additional or alternate effect(s) if desired, as long as the three photos have a style around them. You must use either box-shadow or border-radius but you can use a combination, and can also include the border property. These three images will all have the same style so use the appropriate selector
5.Add the needed CSS property/properties using the selector of your choice to apply rounded corners to the social icon image
6.Add the needed CSS property/properties using the selectors of your choice to add a background image to the two <h2>
elements. You will need to use a text property to move the text away from the edge of the
element so it does not overlap with the background image.
In: Computer Science
In: Computer Science
1. Represent following floating-point numbers in IEEE single-precision (32-bit) format: a. -0.1875, b. 0.46875
2. What is the decimal value of the following IEEE single-precision (32-bit) floating-point numbers (which are shown in hexadecimal)? a. 3F400000, b. BE000000
In: Computer Science
Assuming integers are represented as 32-bit words and negative numbers are represented using the 2's complimentary method convert the following decimal numbers to hexadecimal numbers (show your work). a. -1314, b. 2020
In: Computer Science
Assuming integers are represented as 16-bit words and negative numbers are represented using the 2's complementary method, convert the following hexadecimal numbers to decimal numbers a. 0xCAFE, b. 0x4DAD, c. 0xFACE
In: Computer Science
Research and describe
1. User Interface (UI) best practices * Describe UI best practices and principles. Provide examples of a few principles that you come across. Provide examples of good and poor UI design.post must be at least 200 words
In: Computer Science
R language
create file Ass2.txt
"("Macauley, Culkin" "Antoine, Doinel" "Ace, Ventura" "Tommy, DeVito" "Oda Mae, Brown" "John, Malkovich" "Sandy, Olsson" "Raymond, Babbitt" "Jack, Sparrow" "Melanie, Daniels" "Stanley, Kowalski" "Darth, Vader" "Jack, Torrance" "Aurora, Greenway" "Sam, Spade" "Hans, Beckert" "Max, Rockatansky" "Tony, Manero")".
a. Import the data into a vector named name and create an email address for each student as follows. The general format of an email address is username (at) domain. For each student, username is the name of the student in lowercase, with a period separating the first name and the last name if a last name is provided; and domain is IloveR.edu. Name the vector that contains the email addresses as email.
b. Export the data in email to a plain-text file named email.txt in the following format: • Use the column names as the header line.
• There should be no quotes or row names. • Use the comma as a separator.
In: Computer Science
Using Python
Define a Student class. A Student class needs to have two attributes, the student_name and strudent_grade . It also has three methods as follows: set_grade(grade) that sets the grade of the student. get_grade returns the grade of the student. print_student_info that print the name and grade of student in a formatted string.
In the math_utils.py file define a function called average_grade(roster) . This method accepts as input a list of Student Objects and returns the average of the current roster.
In the app.py file, create a main function, to create a roster of 10 students, print the list of students, and print the average score of the current roster. You can either populate the student roster interactively (i.e. by using the input method to prompt the user from the console) or hard-code the student information in your code.
The app.py file must use the Student class, and the average_grade method you defined the mymodules module.
In: Computer Science
Before you begin your program: Create a text file in your project folder with 20 "quirky sayings"/fortunes (the only requirement is that they be appropriate for display in class), In your program you will Create a list by reading those 20 fortunes from your file Ask the user how many fortunes he/she wants to see. store the value in a variable Inside of a loop (loop as many times as the user asked) select a random answer from your list of fortunes wait for the user to press the enter key (the easy way is to use the Scanner's nextLine method) Note that it is quite possible that you will see some fortunes more than once while not seeing some at all.
In: Computer Science
Write a function matrix_power(A, n) that computes the power An using Boolean arithmetic and returns the result. You may assume that A is a 2D list containing only 0s and 1s, A is square (same number of rows and columns), and n is an integer ≥ 1. You should call your previously written matrix multiply boolean function.
Example: Let R = [ [0, 0, 0, 1], [0, 1, 1, 0], [0, 0, 0, 1], [0, 0, 1, 0] ]
Then calling matrix power(R, 2) should return [ [0, 0, 1, 0], [0, 1, 1, 1], [0, 0, 1, 0], [0, 0, 0, 1] ]
**This is to be written in a python code.
In: Computer Science
QUESTION 31
In Classic Three-Layer Hierarchical Model, the ___________ layer connects network services to the lower layer and implements policies regarding security, traffic loading, and routing.
|
Access |
||
|
Distribution |
||
|
Core |
||
|
User |
QUESTION 32
Which of the following is a RFC1918 address?
|
172.168.1.1 |
||
|
192.168.255.1 |
||
|
192.16.1.1 |
QUESTION 33
In modern network design, a _________ has become a method to subdivide physical switch-based LANs into many logical LANs.
|
STP |
||
|
VLAN |
||
|
DTP |
||
|
VTP |
|
"Test, optimize, and document design", "Monitor and optimize network performance", "Develop logical design" |
||
|
"Develop logical design", "Monitor and optimize network performance" , "Test, optimize, and document design" |
||
|
"Develop logical design", "Test, optimize, and document design", "Monitor and optimize network performance" |
||
|
"Monitor and optimize network performance", "Develop logical design", "Test, optimize, and document design" |
QUESTION 35
Performance can be expressed as a percent uptime per year, month, week, day, or hour, compared to the total time in that period.
True
False
QUESTION 36
Throughput is the data carrying capacity of a circuit.
True
False
QUESTION 37
Route summarization is the method of including many subnets in a few routing entries. It helps conserve routers memory and bandwidth when updating network routes.
True
False
QUESTION 38
When characterizing addressing, any address oddities, such as Discontiguous Subnets, should be noted down for analysis.
True
False
QUESTION 39
_________ provides the following management services:
|
Fault management |
||
|
Configuration management |
||
|
Accounting management |
||
|
Performance management |
QUESTION 40
The network should not fail more than once every 100 days and it should be fixed within 5 hours. Which of the following is the availability of this network?
| A. |
99.79% |
|
| B. |
99.89% |
|
| C. |
99.69% |
|
| D. |
99.99% |
In: Computer Science
Write a program (name it firstMiddleLast _yourInitials.java (yourInitials represents your initials) that will:
1. Ask the user (include appropriate dialog) to enter their:
first name
middle name
last name
save each of the above as a String variable as follows:
firstName
middleName
lastName
2. Print to the screen the number of characters in each of the
names (first, middle and last)
3. Print to the screen total number of characters in all three names. Include appropriate dialog in your output.
4. Print to the screen the initials of the person (first letter of the first, middle and last names) in all capitals with no space or lines between them. For example JFK.
5. Print to the screen the total of the ASCII values of the initials printed in #4 above. For example the initials JFK would sum to 219 (74 + 70 + 75). Remember that the ASCII values are as follows and to find the ASCII value of a single character by casting the character to an int by using (int).
|
A |
65 |
N |
78 |
|
B |
66 |
O |
79 |
|
C |
67 |
P |
80 |
|
D |
68 |
Q |
81 |
|
E |
69 |
R |
82 |
|
F |
70 |
S |
83 |
|
G |
71 |
T |
84 |
|
H |
72 |
U |
85 |
|
I |
73 |
V |
86 |
|
J |
74 |
W |
87 |
|
K |
75 |
X |
88 |
|
L |
76 |
Y |
89 |
|
M |
77 |
Z |
90 |
In: Computer Science
Please note: This is in Visual Basic.
Create an application. Add two text boxes, a label, and a button to the form. The button’s Click event procedure should assign the contents of the text boxes to Double variables named dblNum1 and dblNum2. It then should divide the dblNum1 variable’s value by the dblNum2 variable’s value, assigning the result to a Double variable named dblAnswer. Display the answer in the label. Code the procedure. Save the solution and then start the application. Test the application using the numbers 6 and 2; the number 3 appears in the label control. Now test it using the numbers 6 and 0. The infinity symbol (∞) appears in the label control because the application is trying to divide a number by 0. Add a selection structure to the procedure. The selection structure should perform the division and display the quotient only if the value in the dblNum2 variable is not 0; otherwise, it should display N/A in the label. Save the solution and then start and test the application. Close the solution.
In: Computer Science