In C programming, Thanks
Write a program to determine which numbers in an array are inside a particular range. The limits of the range are inclusive.
You have to write a complete "C" Program that compiles and runs in Codeblocks. (main.c)
1. Declare an array that can contain 5 integer numbers. Use as the name of the array your LastName.
2. Use a for loop to ask the user for numbers and fill up the array using those numbers.
3. Ask the user for the lower limit of the range.
4. Ask the user for the upper limit of the range.
5. Use a for loop to check all the numbers in the array and print the numbers inside the range.
The following is an example of how your program should look when you execute it:
Enter a number to store in the array: 10
Enter a number to store in the array: 90
Enter a number to store in the array: 145
Enter a number to store in the array: 94
Enter a number to store in the array: 97
Enter the lower limit of the range: 90
Enter the upper limit of the range: 99
The numbers in the range are: 90, 94, 97
In: Computer Science
how to count the word of occurance in the text file
example input text file : "test1.txt
hello : 1
good : 1
morning: 1
how : 1
are : 2
you : 2
good : 1
example output text file : "test2.txt"
1 : 4
2 : 2
3 : 0
4 : 0
5 : 0
In: Computer Science
C++ . It should all be in one code and using WHILE loops
2. Write a piece of code that asks the user for a number and adds up the even numbers from 1 to that entered number.
3. Write a piece of code that asks the user for 2 numbers and adds up the numbers between and including the numbers.
4. Write another piece of code that asks the user for a random file name and adds all of the numbers in the file and reads until the end of the file.
In: Computer Science
Part 2
Write a C++ program that prompts the user for an Account Number(a whole number). It will then prompt the user for the initial account balance (a double). The user will then enter either w, d, or z to indicate the desire to withdraw an amount from the bank, deposit an amount or end the transactions for that account((accept either uppercase or lowercase). You must use a switch construct to determine the account transaction and a do…while loop to continue processing.
Test Run:
Enter the account number: 1
Enter the initial balance: 5000
SAVINGS ACCOUNT TRANSACTION
(W)ithdrawal
(D)eposit
(Z) to end account transaction
Enter first letter of transaction type (W, D or Z): w
Amount: $1000
Balance for this account is now: $4000.00
SAVINGS ACCOUNT TRANSACTION
(W)ithdrawal
(D)eposit
(Z) to end account transaction
Enter first letter of transaction type (W, D or Z): d
Amount: $500
Balance for this account is now: $4500.00
SAVINGS ACCOUNT TRANSACTION
(W)ithdrawal
(D)eposit
(Z) to end account transaction
Enter first letter of transaction type (W, D or Z): z
No more changes.
Balance for this account is now: $4500.00
Press any key to continue . . .
In: Computer Science
I want a unique c++ code for the following. PLEASE HIGHLIGHT THESE FUNCTIONS WITH COMMENTS .
Add the following functions to the class arrayListType: Then, update the main function to test these new functions.
arrayListType.h :
#ifndef H_arrayListType
#define H_arrayListType
class arrayListType {
public:
bool isEmpty() const;
bool isFull() const;
int listSize() const;
int maxListSize() const;
void print() const;
bool isItemAtEqual(int location, int item) const;
//Function to determine whether item is the same as the item in the
list at the position specified by location.
//Postcondition: Returns true if list[location] is the same as
item; otherwise,
// returns false. If location is out of range, an appropriate
message is displayed.
void removeAt(int location);
//Function to remove the item from the list at the
//position specified by location
//Postcondition: The list element at list[location]
is removed and length is decremented by 1.
// If location is out of range appropriate message is
displayed.
void retrieveAt(int location, int& retItem) const;
//Function to retrieve the element from the list
//at the position specified by location
//Postcondition: retItem = list[location]
// If location is out of range, an
// appropriate message is displayed.
void clearList();
//Function to remove all the elements from the list After this
operation, the size of the list is zero.Postcondition: length =
0;
arrayListType(int size = 100);
//Constructor. The default array size is 100.
//Postcondition: The list points to the array, length = 0, and
maxSize = size;
arrayListType (const arrayListType& otherList);
//Copy constructor
~arrayListType();
//Destructor
//Deallocate the memory occupied by the array.
void insertAt(int location, int insertItem);
void insertEnd(int insertItem);
void replaceAt(int location, int repItem);
int seqSearch(int searchItem) const;
void remove(int removeItem);
private:
int *list; //array to hold the list elements
int length; //variable to store the length of the list
int maxSize; //variable to store the maximum
//size of the list
};
#endif
arrayListTypeIm.cpp :
#include
#include "arrayListType.h"
using namespace std;
bool arrayListType::isEmpty() const
{
return (length == 0);
} //end isEmpty
bool arrayListType::isFull() const
{
return (length == maxSize);
} //end isFull
int arrayListType::listSize() const
{
return length;
} //end listSize
int arrayListType::maxListSize() const
{
return maxSize;
} //end maxListSize
void arrayListType::print() const
{
for (int i = 0; i < length; i++)
cout << list[i] << " ";
cout << endl;
} //end print
bool arrayListType::isItemAtEqual(int location, int item)
const
{
if (location < 0 || location >= length)
{
cout << "The location of the item to be removed "
<< "is out of range." << endl;
return false;
}
else
return (list[location] == item);
} //end isItemAtEqual
void arrayListType::removeAt(int location)
{
if (location < 0 || location >= length)
cout << "The location of the item to be removed "
<< "is out of range." << endl;
else
{
for (int i = location; i < length - 1; i++)
list[i] = list[i+1];
length--;
}
} //end removeAt
void arrayListType::retrieveAt(int location, int& retItem)
const
{
if (location < 0 || location >= length)
cout << "The location of the item to be retrieved is "
<< "out of range" << endl;
else
retItem = list[location];
} //end retrieveAt
void arrayListType::clearList()
{
length = 0;
} //end clearList
arrayListType::arrayListType(int size)
{
if (size <= 0)
{
cout << "The array size must be positive. Creating "
<< "an array of the size 100." << endl;
maxSize = 100;
}
else
maxSize = size;
length = 0;
list = new int[maxSize];
} //end constructor
arrayListType::~arrayListType()
{
delete [] list;
} //end destructor
arrayListType::arrayListType(const arrayListType&
otherList)
{
maxSize = otherList.maxSize;
length = otherList.length;
list = new int[maxSize]; //create the array
for (int j = 0; j < length; j++) //copy otherList
list [j] = otherList.list[j];
}//end copy constructor
//===========
void arrayListType::insertAt(int location, int insertItem)
{
if (location < 0 || location >= maxSize)
cout << "The position of the item to be inserted "
<< "is out of range." << endl;
else if (length >= maxSize) //list is full
cout << "Cannot insert in a full list" << endl;
else
{
for (int i = length; i > location; i--)
list[i] = list[i - 1]; //move the elements down
list[location] = insertItem; //insert the item at
//the specified position
length++; //increment the length
}
} //end insertAt
void arrayListType::insertEnd(int insertItem)
{
if (length >= maxSize) //the list is full
cout << "Cannot insert in a full list." << endl;
else
{
list[length] = insertItem; //insert the item at the end
length++; //increment the length
}
} //end insertEnd
int arrayListType::seqSearch(int searchItem) const
{
int loc;
bool found = false;
loc = 0;
while (loc < length && !found)
if (list[loc] == searchItem)
found = true;
else
loc++;
if (found)
return loc;
else
return -1;
} //end seqSearch
void arrayListType::remove(int removeItem)
{
int loc;
if (length == 0)
cout << "Cannot delete from an empty list." <<
endl;
else
{
loc = seqSearch(removeItem);
if (loc != -1)
removeAt(loc);
else
cout << "The item to be deleted is not in the list."
<< endl;
}
} //end remove
void arrayListType::replaceAt(int location, int repItem)
{
if (location < 0 || location >= length)
cout << "The location of the item to be "
<< "replaced is out of range." << endl;
else
list[location] = repItem;
} //end replaceAt
main.cpp :
#include
#include "arrayListType.h"
using namespace std;
int main()
{
arrayListType intList(25);
int number;
cout << "List 8: Enter 8 integers: ";
for (int count = 0; count < 8; count++)
{
cin >> number;
intList.insertEnd(number);
}
cout << endl;
cout << "Line 16: intList: ";
intList.print();
cout << endl;
cout << "Line 18: Enter the number to be "
<< "deleted: ";
cin >> number;
cout << endl;
intList.remove(number);
cout << "Line 22: After removing " << number
<< " intList: ";
intList.print();
cout << endl;
cout << "Line 25: Enter the search item: ";
cin >> number;
cout << endl;
if (intList.seqSearch(number) != -1)
cout << "Line 29: " << number
<< " found in intList." << endl;
else
cout << "Line 31: " << number
<< " is not in intList." << endl;
return 0;
}
In: Computer Science
Upon completion of this exercise, you will have demonstrated the ability to:
INTRODUCTION
Your instructor will assign one of the following projects, each involves the user of loops and the construction of conditions to control them.
CODING STANDARDS
The following coding standards must be followed when developing your program:
PROJECTS
In: Computer Science
We are using javaCC notation.This is the full question
Given the following grammar:
Which of the following strings are correct according to this grammar?
Group of answer choices
A C C D X X Y
X X Y
A B C D
A X
A B C D
A C D C
A B C D X Y
A X X X
A X Y X C D
A B X X Y
B C D
A
B X X Y
In: Computer Science
The following grammar for a program has a problem with semicolons:
Use JavaCC to update
When an if statement has a block after it, the block sometimes must end with a semicolon sometimes but not all the time.
In: Computer Science
Write a pro-active password checker that checks to make sure that a user entered password meets certain requirements. You must implement a simple program that prompts the user for two String values, a password and the same password again for confirmation. For the purposes of this lab, a legal password must have all of the following properties:
▪ Length of at least 8 characters
▪ Starts with a lower case letter
▪ Ends with a numerical digit
▪ Has one Uppercase
▪ Is exactly equal to the repetition of the password typed for confirmation
Complete your program to prompt the user to enter a password and a confirmation as explained above. If the password is shorter than 8 characters, print Password is too short! Otherwise, if the password does not start with a lower case letter, print Password must start with a lower case letter! Otherwise, if the password does not end with a digit, print Password must end with a digit! Otherwise, if the password does not match the confirmation, print Passwords do not match! If there is no Uppercase letter in the password print Password must contain uppercase letter! Finally, if all the conditions are satisfied, print Password is valid!
Must be in Java
In: Computer Science
Hello, I am just having a hard time understanding this question. The question is below. I am not supposed to write a program but instead in regular english sentence form just name the methods, fields, and variables I would use for this loan class. Im not really sure what a loan class means as well, thank you for your help.
USING JAVA Given a Loan class, name the necessary fields and methods that we would need in this class. Be creative in your naming of variables and methods.
In: Computer Science
Using Python 3, define mySum function that supposed to return the sum of a list of numbers (and 0 if that list is empty), but it has one or more errors in it. Write test cases to determine what errors there are.
In: Computer Science
Python Knapsack Problem:
Acme Super Store is having a contest to give away shopping sprees to lucky families. If a family wins a shopping spree each person in the family can take any items in the store that he or she can carry out, however each person can only take one of each type of item. For example, one family member can take one television, one watch and one toaster, while another family member can take one television, one camera and one pair of shoes.
Each item has a price (in dollars) and a weight (in pounds) and each person in the family has a limit in the total weight they can carry. Two people cannot work together to carry an item. Your job is to help the families select items for each person to carry to maximize the total price of all items the family takes. Write an algorithm to determine the maximum total price of items for each family and the items that each family member should select.
***In python:***
Implement your algorithm by writing a program named “shopping.py”. The program should satisfy the specifications below.
Input: The input file named “shopping.txt” consists of T test cases
T (1 ≤ T ≤ 100) is given on the first line of the input file.
Each test case begins with a line containing a single integer number N that indicates the number of items (1 ≤ N ≤ 100) in that test case
Followed by N lines, each containing two integers: P and W. The first integer (1 ≤ P ≤ 5000) corresponds to the price of object and the second integer (1 ≤ W ≤ 100) corresponds to the weight of object.
The next line contains one integer (1 ≤ F ≤ 30) which is the number of people in that family.
The next F lines contains the maximum weight (1 ≤ M ≤ 200) that can be carried by the ith person in the family (1 ≤ i ≤ F).
Output: Written to a file named “results.txt”. For each test case your program should output the maximum total price of all goods that the family can carry out during their shopping spree and for each the family member, numbered 1 ≤ i ≤ F, list the item numbers 1 ≤ N ≤ 100 that they should select.
Sample Input from input file
2
3
72 17
44 23
31 24
1
26
6
64 26
85 22
52 4
99 18
39 13
54 9
4
23
20
20
36
Sample Output:
Test Case 1
Total Price 72
Member Items
1: 1
Test Case 2
Total Price 568
Member Items
1: 3 4
2: 3 6
3: 3 6
4: 3 4 6
In: Computer Science
In: Computer Science
1. Explain how two controls can be set up to share the same event handler. How can the event handler tell which control generated the event?
2. Which user action generates three separate mouse events? Which events? Why?
3. Compare and contrast event handlers and change listeners.
Hello, I would really appreciate it if these 3 questions could be explained to me. These are in reference to the JAVA programming language. Specifically the JAVA GUI. I greatly appreciate a clear and understandable explanation. I WILL NOT BE COPY AND PASTING YOUR ANSWERS. Instead, I want to learn so I can form it in my own words.
In: Computer Science
Java Program. !ONLY USING WHILE LOOPS!
(Completed but with errors, wanted to revise could anyone re-create this?)
Write a program to keep track of the number of miles you have driven during an extended vacation and the number of gallons of gasoline you used during this time, recorded at weekly intervals. This vacation will last over several weeks (the precise number of weeks while making the program is unknown to the coder). Ask the user to enter the number of miles driven afterward ask them how many gallons of gasoline they purchased for each week of the vacation. If the user enters -99 when asked for the number of miles driven, the vacation is over and the program will end by printing "Vacation Over!". Express all numeric values rounded to the nearest hundredth.
The task is to create this in Java using only while loops.
Thank you.
In: Computer Science