HTML 5
(Creating an Autocomplete Form with a datalist) Create an autocomplete input element with an associated datalist that contains the days of the week.
In: Computer Science
In: Computer Science
in MIPS assembly, ask a user for two numbers and to either enter a '1' for addition or '2' for subtraction. using jal, jump to the appropriate procedure for additing or subtracting. then print out result and ask if there is another calculation (terminate program if 'no').
In: Computer Science
In coding language C, Write a program in which will use floating point variable (input=232.346) and print out: 1. scientific notation form of input. 2. floating point form of input with total width 12 (default right aligned). 3. floating point form of input with total width 12 (default right aligned) and add 0s for unused space. 4. floating point form of input with total width 12 (left aligned). 5. floating point form of input with total width 12 (default right aligned) and limit number of digits after decimal point to 2 i.e. (precision of 2 digits)
In: Computer Science
C++
Here is a program that to validate the ISBN number from user typed and output "Valid" if the number is valid, and "Invalid" otherwise.
I want to change this program to read the file, and to validate the ISBN number from the file.
Please add comments.
#include <iostream>
#include <string>
using std::cin;
using std::cout;
using std::string;
// remove dashes convert letters to upper case
string normalize(const string &isbn) {
string ch;
for (char i : isbn) {
if (i == '-') {
continue; // if "-" then skip it
}
if (isalpha(i)) {
i = toupper(i); // Check uppercase
}
ch += i;
}
return ch;
}
// return the number of digits in to the string
size_t numDigits(string &str) {
size_t numDigits = 0;
for (char ch : str) {
if (isdigit(ch)) {
++numDigits;
}
}
return numDigits;
}
enum ValidationCode {
Ok, // validation passed
NumDigits, // wrong number of digits
ExtraChars // extra characters in isbn
};
enum ValidationCode validate(string &isbn) {
string normal = normalize(isbn);
size_t count = numDigits(normal);
if (count != 10) {
return NumDigits;
}
if (normal.size() == 10 || normal.size() == 11 && normal[10] == 'X') {
return Ok;
}
return ExtraChars;
}
int main() {
string str;
while (cin >> str) {
switch (validate(str)) {
case Ok:
cout << str << " is a valid isbn\n";
break;
case NumDigits:
cout << str << " doesn't have 10 digits\n";
break;
case ExtraChars:
cout << str << " has extra characters\n";
break;
default:
cout << "ERROR: validate(" << str << ") return an unknown status\n";
break;
}
}
}
isbn_data.text
1-214-02031-3
0-070-21604-5
2-14-241242-4
2-120-12311-x
0-534-95207-x
2-034-00312-2
1-013-10201-2
2-142-1223
3-001-0000a-4
done
In: Computer Science
In: Computer Science
This code needs to run a working Reverse Polish Calculator, but when I input my commands it only pops my inputs never push them. So my answer is always zero.
Here is my code.
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
struct Node
{
int element;
struct Node *next;
};
//Global variable
struct Node *top = NULL;
void push(int ele)
{
struct Node *newNode;
newNode = (struct Node *) malloc(sizeof(struct Node));
newNode->element = ele;
newNode->next = top;
top = newNode;
}
void pop()
{
struct Node *temp;
temp = top;
if(top == NULL)
printf("Stack is empty!!!\n");
else
{
top = top->next;
printf("%d is popped from the stack\n", temp->element);
free(temp);
}
}
bool isEmpty()
{
if(top == NULL)
return true;
else
return false;
}
int returnTopElement()
{
return top->element;
}
void printStack()
{
struct Node *temp;
temp = top;
printf("Stack : ");
while(temp != NULL)
{
printf("%d ", temp->element);
temp = temp->next;
}
printf("\n");
}
int oneByOne(){
char test; //taking character input
int num = 0;
int num1;
int num2;
int atleastone = 0;
printf("Enter your inputs separated by a space and the
operation.\n");
printf("Enter ! when you are done.\n");
while(1){
scanf("%c",&test); //take input of current character
printf("%c is user character\n", test);
if(test == '!'){break;} //terminates character
if(test == ' ' || test == '\n'){ //allows for space or newline
input
if(atleastone) //check if at least one previous digit scanned
push(num);
num = 0, atleastone = 0;
continue;
}
else if(test>='0' && test <='9'){
atleastone = 1;
num = num*10 + (test - '0');
continue;
}
if(top == NULL){
printf("This operation is invalid.\n");
break;
}
num1 = returnTopElement(); pop();
if(top == NULL){
printf("This operation is invalid.\n");
break;
}
num2 = returnTopElement(); pop();
if(test == '+');
push(num2+num1); //allows addition
if(test == '-');
push(num2-num1); //allows subtraction
if(test == '*');
push(num2*num1); //allows multiplication
if(test == '/');
push(num2/num1); //allows division
}
if(top == NULL)
return -1;
return returnTopElement();
}
int arrayInput(char** inputArray){
int i = 0;
int atleastone = 0;
int num = 0;
int num1;
int num2;
char test;
while((*inputArray)[i] != '\0'){
test = (*inputArray)[i];i++; //gets char input from function
if(test == '!'){break;} //terminate character
if(test == ' ' || test == '\n'){ //allows for space or newline
input
if(atleastone)
push(num);
num = 0, atleastone = 0;
continue;
}
else if(test >= '0' && test <= '9'){
atleastone = 1;
num = num*10 + (test- '0');
continue;
}
if(top == NULL){
printf("This operation is invalid.\n");
break;
}
num2 = returnTopElement(); pop();
if(test == '+');
push(num2+num1); //allows addition
if(test == '-');
push(num2-num1); //allows subtraction
if(test == '*');
push(num2*num1); //allows multiplication
if(test == '/');
push(num2/num1); //allows division
}
if(top == NULL)
return -1;
return returnTopElement();
}
int main(int argc, const char * argv[]) {
printf("Check oneByone function: \n");
int ans = oneByOne();
if(top == NULL){
printf("The input is invalid.\n");
}
else{
printf("The answer is %d\n", ans);
}
char * e = "23 45 + 3 *";
char ** expression = &e;
printf("\nChecking arrayInput function for %s \n",
*expression);
printf("The above expression is hardcoded in the code itself.
\n");
ans = arrayInput(expression);
if(top == NULL){
printf("The input expression is invalid. \n");
}
else{
printf("The answer of the input expression is %d\n", ans);
}
return 0;
}
In: Computer Science
Explain the importance of awareness when dealing with employees security. Provide an example of two security policies that would help prevent internal employee fraud.
In: Computer Science
2.20 Domain Lab 3.1 -- Velocity Calculator
You may (or may not) need the following constants:
Velocity Calculator Your program should ask the user (in this order) for:
Your program should then calculate and display the resulting final velocity based on the inputs provided.
In: Computer Science
in java please:
Given any integer, print an English phrase that describes the integer (e.g. “One Thousand, Two Hundred Thirty Four”). An ArrayList must be used in your program.
In: Computer Science
In Python:
Write a function called sum_odd that takes two parameters, then calculates and returns the sum of the odd numbers between the two given integers. The sum should include the two given integers if they are odd. You can assume the arguments will always be positive integers, and the first smaller than or equal to the second.
To get full credit on this problem, you must define at least 1 function, use at least 1 loop, and use at least 1 decision structure.
Examples:
sum_odd(0, 5) should return the value 9 as (1 + 3 + 5) = 9
sum_odd(6, 10) should return the value 16
sum_odd(13, 20) should return the value 64
sum_odd(7, 11) should return the value 27
In: Computer Science
Write a recursive and an iterative function to calculate the nth element in a Fibonacci sequence. A Fibonacci sequence is defined as the element 1, followed by another 1, and each element thereafter is the sum of the previous two elements. For example, the first 9 elements of a Fibonacci sequence are:
This famous sequence was originally used to predict the growth of rabbit populations!
Once you have each of the functions working for n equal to 40, determine which method is more efficient by timing the two separate function calls and printing out the time required for each method call to return the 40th element in the sequence. Return the 40th element to main and print it. After that, print out a complete Fibonacci sequence from element 1 to element 40, along with its position number.
. .
. .
This last part should not be timed.
The timer function you need for this Project is:
Date d1 = new Date();
long milliseconds = D1.getTime();
OR
long start = System.currentTimeMillis();
Turn in the source, output, and a short paragraph explaining the reason the two methods took different amounts of time to execute.
Please write in JAVA
and please write recursive part and iterative part separate!
In: Computer Science
In: Computer Science
There are PRO's and CON's to mounting and emulating the suspect system. Post a short discussion item on some PRO's and CON's of booting up a forensic image.
In: Computer Science