I have finished writing the code for the following program. I have concerns with the pseudo-code that I have written and the flow chart seems really complicated. I dont know how to build it. Here is the question:
An Internet service provider has three different subscription packages for its customers:
Package A: For $9.95 per month 10 hours of access are provided. Additional hours are $2.00 per hour.
Package B: For $14.95 per month 20 hours of access are provided. Additional hours are $1.00 per hour.
Package C: For $19.95 per month unlimited access is provided.
Write a program that calculates a customer s monthly bill. It should ask which package the customer has purchased and how many hours were used. It should then display the total amount due.
Input Validation: Be sure the user only selects package A, B, or C. Also, the number of hours used in a month cannot exceed 744
Here is my program:
#include <iostream>
using namespace std;
int main() {
char package;
int hours;
[code]....
What should be my pseudocode and flowchart ? Can i copy and paste my pseudocode here ?
I am having problems understanding where this code is wrong as I believe that I am not receiving the correct outputs. I have truncated the code to the most pertinent.
The algorithm asks that every value in array1 be divided by array2
and if that value is less than the ratio * array3 (percentage filter) then output.
I have no problem with the code with the exception of abs(ratio*array3[m]
Assuming that the ratio = 1 then all values get outputted, I want the array1 (first value) to have the first value in array3 assigned to it, the second value in array1 to have the second value in array3 to be assigned.
So:
array1 (1.0) with array3 (0.05) array1 (2.0) with array3 (0.06) etc. or array1 (1.0) with array3 (0.05) array1 (3.0) with array3 (0.07)
I'm doing a practice problem where I need to read pseudo code and understand what it does.
For this code, I believe it will move the robot forward while i<650, so it moves it forward for 650 steps in total. Then it sets the motors to 0 when it's finished.
Code: while(i<650) { rotateCW(2); rotateCCW(1); Delay1KTCYx(50); i++; LATD=0x00; //Set all Port D to 0 }
This code I'm having the most trouble with. So while(1) the pot(potentiometer) read's the ADC. Then it scales the adc, not 100% sure what the +20 and *.22 mean, I think it has to do with binary conversions?
Now it sets pin 1 of port 1 to 0, delays based on pot above, and sets it back to 1, and delays again. I assume something to do with controlling motor speed based on the potentiometer.
Code: void main(void){TRISD = 0x00; // Setting port D to outputs LATDbits.LATD0 = 1; // Setting bit 0 of port D to 1 while(1) { pot = readADC(); pot = pot * 0.2297 + 20;
[Code] ......
My best guess is: The car moves forward 400 steps, stop, turn right for 230 steps, stop. At this point it would begin moving straight, and it would turn left/right as needed to keep the robot in the center of the track.
Code: void main(void) { for(i=0;i<400;i++) { rotateCW(2,motor); //Rotate motor two (one step) rotateCCW(1,motor); //Rotate motor one (one step) Delay1KTCYx(50);
Set found to false. Set position to -1. Set index to 0. While found is false and index < number of elements If list[index] is equal to search value found = true. position = index. End If Add 1 to index. End While. Return position
Design an algorithm using flowchart or pseudo-code to prompt the user for a series of positive integer values. Calculate the average of these values and display the average at the end of the program. Assume that the user types the sentinel value -1 to indicate end of data entry.
Sample input-output: Enter a positive integer (-1 to end) : 5 Enter a positive integer (-1 to end) : 7 Enter a positive integer (-1 to end) : 6 Enter a positive integer (-1 to end) : -1
The average value is: 6
I searched online and found out this solution however it is only for three numbers.Is there any way of modifying this to include the sum of x numbers / number of x(integers) to find the average?
I am having trouble understanding what I need to do to halt the flow of a program until a video file finishes playing. So far I have accomplished getting the video to play, but the program continues while the video is playing rendering the content of the program on top of the video making it not seen.
My goal is to make the video play, then once it has finished the rest of the program should run.
So far I have this in the start up area of my code:
//Initialize components for DirectShow to stream a video at start-up CoInitialize(NULL); //creates filter graph manager
[Code].....
After this code runs once, the program proceeds immediately into the loop where my update and render functions for the program runs. Preferably, I want to stop just the render function while allowing the update to continue to check if the user presses a key to skip the video. What do I need to add to the code to do this?
I am attempting to write some code for a flow meter and LEDs using my Arduino. I need the flow meter to count a certain quantity of fluid, then light up an LED which corresponds to that quantity. I found this code on the internet and it was exactly what I needed but when I opened up the serial monitor to see if it worked it didn't. I have finally fixed the issue with it not counting anything at all, but it is still acting as if it was measuring the rate. how it counts and keeps track of how much fluid in total has passed through the flow meter ?
volatile int NbTopsFan; //variable to accumulate the number of pulses float Calc = 0; //the volume flowed since measurement started, liters void pulse() //This is the function that the interupt calls int hallsensor = 2; //The pin location of the sensor
const int led1Pin = 3; //pin for LED corresponding to volume1 const int led2Pin = 4; //pin for LED corresponding to volume2
I have a class 'A' which is almost perfect for my needs. Class 'B' uses class 'A' I've now designed Class 'C' and Class 'D' and noticed that there is a good chunk of code in class 'B', 'C' and 'D' for using Class 'A' is duplicated. I've separated out this code in specific, standalone functions in each of the classes. Now I'm wondering where this code should go. At the moment, the functions are duplicated in the three calling classes (B, C and D). Placing the functions into class 'A' would break the single responsibility principle. Inheritance to add functionality would likely break both SRP and LSP. The one that seems that it may work is composition.
However, Is designing a complete class just for a few functions over kill?
Would it be valid for classes 'B', 'C' and 'D' to access both the new class 'E' (which would depend on A) and the old class 'A' (which would have to be the same instance as the instance in the new class 'E'), or should the new class 'E' provide sufficient functionality so that Classes B, C and D don't need to access Class A directly? It would seem that its then an incomplete interface of the original object with additional functionality (ie, incompatible) Or should I do it a completely different way?
I'm using maps and writing files for the first time and I get a crazy compiler error when I try to compile the following code.
//map is named schedules // saveSchedule() is a member of the Schedule class that writes a vector of objects to disk, or is supposed to ofstream newFile("sched.txt"); map<string,Schedule>::iterator in;
This project is a Atmega 2560 connected to a serial GLCD screen.I've got serial communication working perfectly.Now as you can see I wrote a function that sends 1 single character to the UDR1.I wrote a function that uses this first function for sending entire words (strings).All of this works great.
Next challenge is writing a "int byte" to the GLCD screen.In this case the variable "voltage" has a value of 100.I'd like to write that 100 to the serial display via the uart.But whenever I do this the screen reads this 100 as a ascii decimal number... (= d)
I've tried things like
LCD_PrintStr("voltage"); (Result: The word voltage shows up on the screen) LCD_Write(voltage); (Result: write ascii letter for dec 100 (= d ))
I'm writing a program using Huffman algorithm to compress text file. I have tested my program by just printing the printing ASCII character to file and it worked fine. However, now I have to implement using bits and my program doesn't work. It seems like I'm not reading or writing the right bits. Here is the result of my testing:In the input file I put abc the input file to compress it. Then I uncompress it the out out is aaa. Below is a snippet of how I read and write bits
Code: class BitInput { istream& in; // the istream to delegate to char buf; // the buffer of bits int nbits; public:
I have a question about an issue I am having on my final project. Within my ItemEntry.cs form, I am trying to get the application to append the already existing .txt file, rather than prompt the user to replace it. I can't seem to get the StreamWriter and FileStream to allow the user to write to the file.
Code: using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq;
I am trying to write a structure to a file. Example say the structure has two variables x and y . I want to write a function which modifies these variables and stores the modified version on a file. Such that next time I call the function . it has the values from the previous write. Here's an example of my code .
// do some calculations. fwrite(mystruct, sizeof(MYSTRUCT), 1, fp); fclose(fp)
//return some value }
The problem is that each time I run the program it shows the initialized value of the variables and not the value from last write. I guess the write isn't successful because when I open in w+ mode. i get the error file could not be opened and then i have to delete the file and re create it....
Code: #include<stdio.h> #include<string.h> #define a 9 #define b 9 #define c 3 int main() {
[Code] .....
In practice section there was a challenge to print up numbers in letters up to billion including negatives I didn't look at the solution and came up with this but it is getting difficult after this point....
I have a text file containing 500 signed decimal numbers. My task is to read each entry and convert into a 16-bit 2's complement representation (binary number) and write into the another text file.