Questions
C++ Please Fill in for the functions for the code below. The functions will be implemented...

C++ Please

Fill in for the functions for the code below. The functions will be implemented using vectors. Additional public helper functions or private members/functions can be used. The List class will be instantiated via a pointer and called similar to the code below:

---the code can be general (can be tested with any int main() test function)---

Stack *ptr = new Stack();

ptr->push(value);

int pop1 = ptr->pop();

int pop2 = ptr->pop();

bool isEmpty = ptr->empty();

class Stack{

    public:

// Default Constructor

Stack() {// ... }

// Push integer n onto top of stack

void push(int n) {// ... }

// Pop element on top of stack

int pop() {// ... }

// Get the top element but do not pop it (peek at top of stack)

int top() {// ... }

// Return whether the stack is empty or not

bool empty() {// ... }

};

In: Computer Science

Create java class with name MyClass1 Instructions for MyClass1 For this portion of the assignment you...

Create java class with name MyClass1

Instructions for MyClass1

For this portion of the assignment you will need to create a java class of your own to model some objects in the real world or your own imagination. your classes should have at least three instances variables, accessor and mutator methods for each of those instance variables, one constructor method of any type, as well as an overridden toString method that will display every field value as part of a String. Use meaningful identifiers for the name of  class.

Demonstrate that your class work appropriately by creating instances of each in the MainClass class which contains a main method

In: Computer Science

Write the equations for carry-out bits for a 4-bit carry lookahead adder. Draw its diagram and...

Write the equations for carry-out bits for a 4-bit carry lookahead adder. Draw its diagram and label all the inputs and the outputs. Compare the delays of the 4-bit ripple-carry and 4-bit carry lookahead adders.

In: Computer Science

Write a C program that counts the number of odd numbers with using function count() within...

Write a C program that counts the number of odd numbers with using function count() within the set. The set has only one negative number which determines the end of set.

In: Computer Science

(previous program) Prompt the user for the filename. Create a new file object sensehat_data_file which opens...

(previous program) Prompt the user for the filename. Create a new file object sensehat_data_file which opens the file in write mode. Write a loop which will read in 20 values for temperature and humidity from the SenseHat. Sleep 0.5 seconds between each reading taken from the SenseHat Write out the temperature and humidity to the file sensehat_data_file, separated by a comma. Close the file.)

ONLY ANWSER problem below

Then Open the file in read only mode. Use a loop to read in the data from the file until all lines have been read. Print out the count for the number of the line read in. Print out the temperature and humidity.

Print in Python .

In: Computer Science

6. There are 3 types of positioning commands in CSS: static, relative, and absolute. Explain how...

6. There are 3 types of positioning commands in CSS: static, relative, and absolute. Explain how each type behaves with regard to: (a) (2 pts) whether or not offsets can be specified (b) (2 pts) where offset values are measured from

In: Computer Science

Write a Java application for a gas station to calculate the total payment for customer. Your...

Write a Java application for a gas station to calculate the total payment for customer.

Your program should display a menu and get customer’s input: ****************************

Welcome to XYZ gas station! Select type of gas (enter R, P, S) Regular - R. plus - P. Super -S: ****************************

Enter the amount of gas in gallons:

In your code, define regular price: $2.45, plus: $2.65, super $2.95 as constant.

Use 7% as sale tax.

Calculate gas subtotal = sale price * gas amount Tax=subtotal * sale tax. Total payment = subtotal + Tax Output nicely to customer the total amount payment:

######################################################

Your payment for (Regular/plus/Super) is $###.

######################################################

Requirements:

Use switch statement for type of gas (case ‘R’, case ‘P’, case ‘S’ , etc)

Use while loop to display the menu. If user inputs anything other than R,P,S, display the menu again.

Use for loop statement to draw lines(**********… and ##############...)

In: Computer Science

Implement a function that returns the maximum number in a given unsorted linked list. For example,...

Implement a function that returns the maximum number in a given unsorted linked list.
For example, there is a linked list 3->5->1->10->9. The printMax() function in max.c should return the maximum number in the linked list, namely 10 in the example.

1. Implement max.c with the completed printMax() function.
2. Provide an explanation for your solution

#include <stdio.h>

typedef struct node {
int value;
struct node *next;
} node;

int printMax(node *first) {
// Your implementation
return 0;
}

int main(void) {
node nodes[5]; //enough to run our tests
int i,array[5] = {3,5,1,10,9};
for(i=0; i < sizeof(nodes)/sizeof(node)-1; i++) {
nodes[i].next = &nodes[i+1];
nodes[i].value = array[i];
}
nodes[i].value = array[4];
nodes[i].next = NULL;
printf("The maximum number is %d\n", printMax(&nodes[0]));
return 0;
}


In: Computer Science

For this assignment, you will be analyzing the Java™ code in the linked Week 3 Analyze...

For this assignment, you will be analyzing the Java™ code in the linked Week 3 Analyze Assignment Zip File, and predicting the results. You will also examine both the code and the output for inconsistencies and clarity. This Java™ code includes examples of for, while, and do-while loops.

Carefully read through the code line by line, then answer the following questions in a Microsoft® Word document:

  1. What is the output of the program as it is written?
  2. What improvement(s) could be made to this code to make the output clearer or more accurate, or to make the code easier to maintain?

Note: You do not have to make the improvements in the Java™ program, although you certainly may. For this assignment, simply describe the things you see that would need to be improved to elevate the code and output to a more professional level. For the code, consider variable names and hardcoding. For the output, consider formatting/punctuation, repetition, accuracy of information, and wording.

/**************************************************************************************
* Program: PRG/420 Week 3
* Purpose: Week 3 Analyze Assignment
* Programmer: Iam A. Student   
* Class: PRG/420   
* Creation Date: 10/22/17
******************************************************************************************
* Program Summary: For, while, and do-while loops
*
* This program demonstrates the syntax for the for, while, and do-while loops. It also
* contains comments that explain why a programmer would use a for loop over a while or do-while
* loop.
*
* Notice the increment operator (i++) and also notice the copious use of println() statements.
* Using System.out.println() is an excellent way to debug your code--especially if your loop code
* is giving unexpected results.
*****************************************************************************************/


package PRG420Week3_AnalyzeAssignment;

public class PRG420Week3_AnalyzeAssignment {

public static void main(String[] args) {
  
// for loops are a good choice when you have a specific number of values
// you want to iterate over and apply some calculation to.
System.out.println("FOR LOOP - Here are the taxes on all 10 prices:");
  
double taxRate = 0.08;
for (int price=1; price<=10; price++) {
System.out.println("The 8% tax on " + price + " dollar(s) is " + "$" + (price * taxRate));
}
System.out.println(""); // Leave a blank space
  
// while loops are a good choice when you're looking through a pile of values
// and want to execute some logic while some condition is true.
// while loops MAY OR MAY NOT EVER EXECUTE, depending on the counter value.
int dollars=1;
System.out.println("WHILE LOOP - Here are the taxes on prices less than $5:");
while (dollars < 5) {
System.out.println("The 8% tax on " + dollars + " dollar(s) is $" + (dollars * taxRate));
dollars++;
}
System.out.println(""); // Leave a blank space
  
// do-while loops are also a good choice when you're looking through a pile of values
// and want to execute some logic while some condition is true.
// do while loops ALWAYS EXECUTE AT LEAST ONCE, no matter what the counter value.
// For example, in the code below, we want to print out the tax only on those
// amounts smaller than $1. But because we're using the do-while loop, the code
// will execute the body of the loop once before it even checks the condition! So
// we will get an INCORRECT PRINTOUT.
dollars=1;
  
System.out.println("DO-WHILE LOOP - Here are the taxes on prices less than $1:");
  
do {
System.out.println("The 8% tax on " + dollars + " dollar(s) is $" + (dollars * 0.08));
dollars++;
} while (dollars < 1);
}
}

In: Computer Science

Assignment (C language) We will simulate the status of 8 LEDs that are connected to a...

Assignment (C language)

We will simulate the status of 8 LEDs that are connected to a microcontroller. Assume that the state of each LED (ON or OFF) is determined by each of the bits (1 or 0) in an 8-bit register (high-speed memory).

  1. Declare a char variable called led_reg and initialize it to 0.
    Assume that the least-significant bit (lsb) controls LED#0 and the most-significant bit (msb) controls LED#7.
  2. In the main function, build and present a menu to the user and enclose it in a loop that ends when the Quit option is chosen. Use if-else or switch-case statements to implement the operations described:

    Menu:
    0. Turn ON LED#4
    1. Turn OFF LED#4
    2. Add 1 to the LED Register
    3. Turn ON all the even numbered LEDs
    4. Turn OFF all the even numbered LEDs
    5. Toggle the state of LED#3.
    6. Shift the values of the LED Register right by 1
    7. Quit
  3. Create a function called: printBinary() with the following properties:

    • one input argument of type char
    • returns nothing
    • prints the binary representation (in 8-bits) of the char input value.
  4. Use the printBinary() function to display the value of the LED register before the menu.

HINTS:

  • Each operation can be performed with a single expression (line of code).
  • Append 0b or 0x to numerical constants to denote binary or hexadecimal values in source code, respectively.
    101010102 = 0b10101010
    FF16 = 0xFF

In: Computer Science

Use counting sort, sort the following numbers: 4, 2, 5, 4, 2, 3, 0, 2, 4,...

Use counting sort, sort the following numbers: 4, 2, 5, 4, 2, 3, 0, 2, 4, 3

In: Computer Science

Objective: Write this program in the C programming language Loops with input, strings, arrays, and output....

Objective:

Write this program in the C programming language

Loops with input, strings, arrays, and output.

Assignment:

It’s an organization that accepts used books and then sells them a couple of times a year at book sale events. Some way was needed to keep track of the inventory.

You’ll want two parallel arrays: one to keep track of book titles, and one to keep track of the prices. Assume there will be no more than 10 books. Assume no more than 100 characters per book title title. Use malloc to allocate the strings in the array.

So, it will be a menu:

  1. Enter book information
  2. List all books and prices
  3. List total value of inventory

In: Computer Science

How do you implement an AVL tree for strings in Java?

How do you implement an AVL tree for strings in Java?

In: Computer Science

Write a Python program that draw simple lollipop (a line and few circles, the line should...

Write a Python program that draw simple lollipop (a line and few circles, the line should attach to the circle, just as regular lollipop, you decide the colors),

In: Computer Science

Change the program to modify the output file by making each sentence a new paragraph (inserting...

Change the program to modify the output file by making each sentence a new paragraph (inserting two carriage returns between every sentence. :) Don't over-think this, but you must have worked through and understand how the program works now in order to modify it. Remember, you want the carriage returns between every SENTENCE, not every LINE.

How would one do this? I'm not to sure how to make it make a new line after a sentence. Any help will be appreciated.

This is the original code that makes it make a new line after every carriage return. I need it to make a new line after every sentence.

Here is the input text file :  

Today we live in an era where information is processed
almost at the speed of light. Through computers, the
technological revolution is drastically changing the way we
live and communicate with one another. Terms such as
“the Internet,” which was unfamiliar just a few years ago, are
very common today. With the help of computers you can send
letters to, and receive letters from, loved ones within
seconds. You no longer need to send a résumé by mail to apply
for a job; in many cases you can simply submit your job
application via the Internet. You can watch how stocks perform
in real time, and instantly buy and sell them. Students
regularly “surf” the Internet and use computers to design
their classroom projects. They also use powerful word
processing software to complete their term papers. Many
people maintain and balance their checkbooks on computers.

Sorry the last question i posted looked very ugly!!

//*************************************************************
// Author: D.S. Malik
//
// Program: Line and Letter Count
// This program reads a text, outputs the text as is, and also
// prints the number of lines and the number of times each
// letter appears in the text. An uppercase letter and a
// lowercase letter are treated as being the same; that is,
// they are tallied together.
//*************************************************************

#include
#include
#include

using namespace std;

void initialize(int& lc, int list[]);
void characterCount(char ch, int list[]);
void copyText(ifstream& intext, ofstream& outtext, char& ch,
int list[]);
void writeTotal(ofstream& outtext, int lc, int list[]);

int main()
{
//Step 1; Declare variables
int lineCount;
int letterCount[26];
char ch;
ifstream infile;
ofstream outfile;

infile.open("textin.txt"); //Step 2

if (!infile) //Step 3
{
cout << "Cannot open the input file."
<< endl;
return 1;
}

outfile.open("textout.out"); //Step 4

initialize(lineCount, letterCount); //Step 5

infile.get(ch); //Step 6

while (infile) //Step 7
{
copyText(infile, outfile, ch, letterCount); //Step 7.1
lineCount++; //Step 7.2
infile.get(ch); //Step 7.3
}

writeTotal(outfile, lineCount, letterCount); //Step 8

infile.close(); //Step 9
outfile.close(); //Step 9
  
return 0;
}

void initialize(int& lc, int list[])
{
int j;
lc = 0;

for (j = 0; j < 26; j++)
list[j] = 0;
} //end initialize

void characterCount(char ch, int list[])
{
int index;

ch = toupper(ch); //Step a

index = static_cast(ch)
- static_cast('A'); //Step b

if (0 <= index && index < 26) //Step c
list[index]++;
} //end characterCount

void copyText(ifstream& intext, ofstream& outtext, char& ch,
int list[])
{
while (ch != '\n') //process the entire line
{
outtext << ch; //output the character
characterCount(ch, list); //call the function
//character count
intext.get(ch); //read the next character
}
outtext << ch; //output the newline character
} //end copyText

void writeTotal(ofstream& outtext, int lc, int list[])
{
int index;

outtext << endl << endl;
outtext << "The number of lines = " << lc << endl;

for (index = 0; index < 26; index++)
outtext << static_cast(index + static_cast('A'))
<< " count = " << list[index] << endl;
} //end writeTotal

This is the code I've got so far to make it ask for what the output file should be named.

//*************************************************************
// Author: D.S. Malik
//
// Program: Line and Letter Count
// This program reads a text, outputs the text as is, and also
// prints the number of lines and the number of times each
// letter appears in the text. An uppercase letter and a
// lowercase letter are treated as being the same; that is,
// they are tallied together.
//*************************************************************

#include
#include
#include

using namespace std;

void initialize(int& lc, int list[]);
void characterCount(char ch, int list[]);
void copyText(ifstream& intext, ofstream& outtext, char& ch,
int list[]);
void writeTotal(ofstream& outtext, int lc, int list[]);

int main()
{
//Step 1; Declare variables
int lineCount;
int letterCount[26];
char ch;
ifstream infile;
ofstream outfile;
string fileName;
  
infile.open("textin.txt"); //Step 2

if (!infile) //Step 3
{
cout << "Cannot open the input file."
<< endl;
return 1;
}

cout << "Please enter the name of the output file: "; <----- This is the new code
getline(cin, fileName); <----- This is the new code

outfile.open(fileName.c_str()); //Step 4 <----- This is the new code

initialize(lineCount, letterCount); //Step 5

infile.get(ch); //Step 6

while (infile) //Step 7
{
copyText(infile, outfile, ch, letterCount); //Step 7.1
lineCount++; //Step 7.2
infile.get(ch); //Step 7.3
}

writeTotal(outfile, lineCount, letterCount); //Step 8

infile.close(); //Step 9
outfile.close(); //Step 9
  
return 0;
}

void initialize(int& lc, int list[])
{
int j;
lc = 0;

for (j = 0; j < 26; j++)
list[j] = 0;
} //end initialize

void characterCount(char ch, int list[])
{
int index;

ch = toupper(ch); //Step a

index = static_cast(ch)
- static_cast('A'); //Step b

if (0 <= index && index < 26) //Step c
list[index]++;
} //end characterCount

void copyText(ifstream& intext, ofstream& outtext, char& ch,
int list[])
{
while (ch != '\n') //process the entire line
{
outtext << ch; //output the character
characterCount(ch, list); //call the function
//character count
intext.get(ch); //read the next character
}
outtext << ch; //output the newline character
} //end copyText

void writeTotal(ofstream& outtext, int lc, int list[])
{
int index;

outtext << endl << endl;
outtext << "The number of lines = " << lc << endl;

for (index = 0; index < 26; index++)
outtext << static_cast(index + static_cast('A'))
<< " count = " << list[index] << endl;
} //end writeTotal

In: Computer Science