In: Computer Science
Write a C++ main program that has the following 5 short independent segments.
1. Show that for unsigned int a,b and a>0, b>0, we can get a+b < a
2. Show that for int a,b and a>0, b>0, we can get a+b < 0
3. Show that for int a,b and a 0
4. Show that for double x and x>0 we can get 1. + x = = 1.
5. Show that for double a,b,c in some cases (a+b)+c != (c+b)+a
In: Computer Science
A shell script foo contains the statement echo “$PATH $x”. Now define x=5 at the prompt, and then run the script. Explain your observations and how you can rectify the behavior.
In: Computer Science
Write a program that simulates the flipping of a coin n times, where n is specified by the user. The program should use random generation to flip the coin and each result is recorded. Your program should prompt the user for the size of the experiment n, flip the coin n times, display the sequence of Heads and Tails as a string of H (for Head) and T (for Tail) characters, and display the frequencies of heads and tails in the experiment. Use functions for full credit.
In: Computer Science
You are to name your package assign1 and your file Palindrome.java.
Palindrome Class
Palindrome
- testString : String
| + Palindrome (String)
+ isPalindrome (): boolean |
The method isPalindrome is to determine if a string is a palindrome. A palindrome, for this assignment, is defined as a word or phrase consisting of alphanumeric characters that reads the same frontwards and backwards while ignoring cases, punctuation and white space. If there are no alphanumeric characters, the string is considered a palindrome. The method should return true if it is a palindrome and false otherwise.
Notice – there is no main, no input and no output for this assignment. You are limited to the following Java library classes.
- String
- Character
Here are the restrictions on this method. Up to 20% penalty if not followed.
1. You may NOT return from the inside of a loop.
2. You may NOT break from the inside of a loop.
3. You may use ONLY ONE loop (either while or do-while).
4. You may NOT copy the String to another String.
5. You may NOT process the String more than one time (only make one
pass
through it).
6. You must STOP processing as early as possible (when you find
that it is or is not
a palindrome). In other words, using a for loop is not a good solution.
In: Computer Science
C# programming
Create a class called A with private integer field x, protected integer field y, public integer field z. Create a class B derived from class A with public integer field d and protected integer field e and private field f.
Write your answer to all three questions below:
In: Computer Science
Python program to simulate estimate the probability that a random chord on a unit-circle (radius one), exceeds the radius of the circle? Repeat the experiment of generating random chords 1,000 times. Record the estimate of the probability that the chord length exceeds the radius
Please use comments to help explain
In: Computer Science
Programming language: Java
If any more information is needed please let me know exactly what you need.
Though there are a bunch of files they are small and already done. Modify the driver file ,Starbuzz coffee, to be able to order each blend and be able to add each condiment to each of the blends. The price should be set accordingly. Be able to: order 1 of each type of beverage, add multiple toppings to each ordered beverage and use each condiment at least once.
Beverage.java:
public abstract class Beverage {
String description = "Unknown Beverage";
public String getDescription() {
return description;
}
public abstract double cost();
}
CondimentDecorator.java:
public abstract class CondimentDecorator extends Beverage
{
public abstract String getDescription();
}
DarkRoast.java:
public class DarkRoast extends Beverage {
public DarkRoast() {
description = "Dark Roast
Coffee";
}
public double cost() {
return .99;
}
}
Decaf.java:
public class Decaf extends Beverage {
public Decaf() {
description = "Decaf Coffee";
}
public double cost() {
return 1.05;
}
}
Espresso.java:
public class Espresso extends Beverage {
public Espresso() {
description = "Espresso";
}
public double cost() {
return 1.99;
}
}
HouseBlend.java:
public class HouseBlend extends Beverage {
public HouseBlend() {
description = "House Blend
Coffee";
}
public double cost() {
return .89;
}
}
Caramel.java:
public class Caramel extends Beverage {
public Caramel() {
description = "Caramel
Coffee";
}
public double cost() {
return 1.35;
}
}
Chocolate.java:
public class Chocolate extends CondimentDecorator {
Beverage beverage;
public Chocolate(Beverage beverage) {
this.beverage = beverage;
}
public String getDescription() {
return beverage.getDescription() +
", Chocolate";
}
public double cost() {
return .20 + beverage.cost();
}
}
Cinnamon.java:
public class Cinnamon extends CondimentDecorator {
Beverage beverage;
public Cinnamon(Beverage beverage) {
this.beverage = beverage;
}
public String getDescription() {
return beverage.getDescription() +
", Cinnamon";
}
public double cost() {
return .15 + beverage.cost();
}
}
Milk.java:
public class Milk extends CondimentDecorator {
Beverage beverage;
public Milk(Beverage beverage) {
this.beverage = beverage;
}
public String getDescription() {
return beverage.getDescription() +
", Milk";
}
public double cost() {
return .10 + beverage.cost();
}
}
Mint.java:
public class Mint extends CondimentDecorator {
Beverage beverage;
public Mint(Beverage beverage) {
this.beverage = beverage;
}
public String getDescription() {
return beverage.getDescription() +
", Mint";
}
public double cost() {
return .15 + beverage.cost();
}
}
Mocha.java:
public class Mocha extends CondimentDecorator {
Beverage beverage;
public Mocha(Beverage beverage) {
this.beverage = beverage;
}
public String getDescription() {
return beverage.getDescription() +
", Mocha";
}
public double cost() {
return .20 + beverage.cost();
}
}
Soy.java:
public class Soy extends CondimentDecorator {
Beverage beverage;
public Soy(Beverage beverage) {
this.beverage = beverage;
}
public String getDescription() {
return beverage.getDescription() +
", Soy";
}
public double cost() {
return .15 + beverage.cost();
}
}
Whip.java:
public class Whip extends CondimentDecorator {
Beverage beverage;
public Whip(Beverage beverage) {
this.beverage = beverage;
}
public String getDescription() {
return beverage.getDescription() +
", Whip";
}
public double cost() {
return .10 + beverage.cost();
}
}
StarbuzzCoffee.java:
public class StarbuzzCoffee {
public static void main(String args[]) {
Beverage beverage = new
Espresso();
System.out.println(beverage.getDescription()
+ " $" + beverage.cost());
Beverage beverage1 = new
Decaf();
beverage1 = new
Soy(beverage1);
beverage1 = new
Mocha(beverage1);
beverage1 = new
Whip(beverage1);
beverage1 = new
Cinnamon(beverage1);
beverage1 = new
Mint(beverage1);
beverage1 = new
Chocolate(beverage1);
System.out.println(beverage1.getDescription()
+ " $" + beverage1.cost());
Beverage beverage2 = new
DarkRoast();
beverage2 = new
Soy(beverage2);
beverage2 = new
Mocha(beverage2);
beverage2 = new
Whip(beverage2);
beverage2 = new
Cinnamon(beverage2);
beverage2 = new
Mint(beverage2);
beverage2 = new
Chocolate(beverage2);
System.out.println(beverage2.getDescription()
+ " $" + beverage2.cost());
Beverage beverage3 = new
HouseBlend();
beverage3 = new
Soy(beverage3);
beverage3 = new
Mocha(beverage3);
beverage3 = new
Whip(beverage3);
beverage3 = new
Cinnamon(beverage3);
beverage3 = new
Mint(beverage3);
beverage3 = new
Chocolate(beverage3);
System.out.println(beverage3.getDescription()
+ " $" + beverage3.cost());
Beverage beverage4 = new
Hazelnut();
beverage4 = new
Soy(beverage4);
beverage4 = new
Mocha(beverage4);
beverage4 = new
Whip(beverage4);
beverage4 = new
Cinnamon(beverage4);
beverage4 = new
Mint(beverage4);
beverage4 = new
Chocolate(beverage4);
System.out.println(beverage4.getDescription()
+ " $" + beverage4.cost());
Beverage beverage5 = new
Caramel();
beverage5 = new
Soy(beverage5);
beverage5 = new
Mocha(beverage5);
beverage5 = new
Whip(beverage5);
beverage2 = new
Cinnamon(beverage5);
beverage2 = new
Mint(beverage5);
beverage2 = new
Chocolate(beverage5);
System.out.println(beverage5.getDescription()
+ " $" + beverage5.cost());
}
}
In: Computer Science
C# programming
Create a class called A with private integer field x, protected integer field y, public integer field z. Create a class B derived from class A with public integer field d and protected integer field e and private field f.
Write your answer to all three questions below:
In: Computer Science
Using C++, Create a singly Linked List of patients list so that you can sort and search the list by last 4 digits of the patient's Social Security number. Implement Node insertion, deletion, update and display functionality in the Linked List.
Each patient's record or node should have the following data:
Patient Name:
Age:
Last 4 digits of Social Security Number:
The program should first display a menu that gives the user the option to:
1) Add a Patient's record (After adding one patient the user should be prompted: Do you want to add another patient's record? 1 for Yes and 0 for No)
2) Modify a Patient's record ((After modifying/updating one patient the user should be prompted: Do you want to add modify patient's record? 1 for Yes and 0 for No)
3) Delete a Patient's Record ((After deleting one patient the user should be prompted: Do you want to delete another patient's record? 1 for Yes and 0 for No)
4) Display a Patient's record
In: Computer Science
Why is the SISP important for developing a RFP?
In: Computer Science
using python 3
2. Write a python program that finds the numbers that are divisible by both 2 and 7 but not 70, or that are divisible by 57 between 1 and 1000.
3. Write a function called YesNo that receives as input each of the numbers between 1 and 1000 and returns True if the number is divisible by both 2 and 7 but not 70, or it is divisible by 57. Otherwise it returns False.
4. In your main Python program write a for loop that counts from 1 to 1000 and calls this YesNo function inside the for loop and will print "The number xx is divisible by both 2 and 7 but not 70, or that are divisible by 57" if the YesNo function returns True. Otherwise it prints nothing. Note the print statement also prints the number where the xx is above.
In: Computer Science
Language java
Rewrite the method getMonthusing the "this" parameter
CODE:
import java.util.Scanner;
public class DateSecondTry
{
private String month;
private int day;
private int year; //a four digit number.
public void writeOutput()
{
System.out.println(month + " " + day + ", " + year);
}
public void readInput()
{
Scanner keyboard = new Scanner(System.in);
System.out.println("Enter month, day, and year.");
System.out.println("Do not use a comma.");
month = keyboard.next();
day = keyboard.nextInt();
year = keyboard.nextInt();
}
public int getDay()
{
return day;
}
public int getYear()
{
return year;
}
public int getMonth()
{
if (month.equalsIgnoreCase("January")) return 1;
else if (month.equalsIgnoreCase("February")) return 2;
else if (month.equalsIgnoreCase("March")) return 3;
else if (month.equalsIgnoreCase("April")) return 4;
else if (month.equalsIgnoreCase("May")) return 5;
else if (month.equalsIgnoreCase("June")) return 6;
else if (month.equalsIgnoreCase("July")) return 7;
else if (month.equalsIgnoreCase("August")) return 8;
else if (month.equalsIgnoreCase("September")) return 9;
else if (month.equalsIgnoreCase("October")) return 10;
else if (month.equalsIgnoreCase("November")) return 11;
else if (month.equalsIgnoreCase("December")) return 12;
else
{
System.out.println("Fatal Error");
System.exit(0);
return 0; //Needed to keep the compiler happy
}
}
}
In: Computer Science
HOW TO PRINT THE CONTENTS OF A TWO-DIMENSIONAL ARRAY USING POINTER ARITHMETIC (USING FUNCTIONS)
(C++)
Fill out the function definition for "void print_2darray_pointer(double *twoDD, int row, int col)".
Should match the output from the function void print_2darray_subscript(double twoDD[][ARRAY_SIZE], int row, int col)
# include
using namespace std;
const int ARRAY_SIZE = 5;
const int DYNAMIC_SIZE = 15;
const int TIC_TAC_TOE_SIZE = 3;
// function definitions:
void print_2darray_subscript(double
twoDD[][ARRAY_SIZE], int row, int col)
// printing array using
subscripts
{
for (int i = 0; i < row;
i++)
{
for (int j = 0;
j < col; j++)
{
cout << twoDD[i][j] << " ";
}
cout <<
endl;
}
cout << endl;
}
void print_2darray_pointer(double *twoDD, int row,
int col)
// print array using pointer
arithmetic
{
for (int i = 0; i < row;
i++)
{
for (int j = 0;
j < col; j++)
{
// I tried doing this, but it didn't work : cout
<< *(*(twoDD + i) + j);
// our 2d array is layed out linearly in memory
as contiguous rows, one after another, there are #row rows
// each row has #col columns
// to compute the offset using pointer
math
// offset from twoDD: #row (i) * #col + #col
(j), result: pointer to array element
// ...
}
cout <<
endl;
}
cout << endl;
}
//------------------------------------------------------------------------------
int main()
{
// complete the following function
implementations
// Q#3 - pointer arithmetic, indexing multidimensional
arrays
double twoDDoubles[ARRAY_SIZE][ARRAY_SIZE] = {
{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}
};
cout << endl << "print 2d array of doubles" << endl << endl;
// print 2ddoubles via subscript operator
print_2darray_subscript(twoDDoubles, ARRAY_SIZE,
ARRAY_SIZE);
// print 2ddoubles via pointer arithmetic
print_2darray_pointer((double*)twoDDoubles,
ARRAY_SIZE, ARRAY_SIZE);
cout << endl << endl;
system("pause");
return 0;
}
In: Computer Science
More definitions and example for the following.
a. CPOE
b. Interface engine
c. Telehealth
d. EMR-EHR-PHR
e. Disc mirroring
In: Computer Science