Cruz Castillo

All generations.

generate functionTue, 02 May 2023

A simple aritmetic and logic unit

void ALU(bool aluop, bool funct, bool bNegate, bool aNegate, bool B[32], bool A[32], bool output[32]) { bool aluop_and = aluop && funct; bool aluop_or = aluop || funct; bool aluop_xor = aluop ^ funct; bool aluop_nor = !(aluop_or); bool aluop_add = aluop_xor; bool aluop_addi = aluop_and; bool aluop_sub = aluop_or; bool aluop_slt = aluop_nor; bool B_logical_negated = bNegate; bool A_logical_negated = aNegate; bool output_value = aluop_add; bool output_value = output_value && (!(A_logical_negated) && !(B_logical_negated)); bool output_

C++
View
generate functionFri, 05 May 2023

Bot program to count the products bought in the supermarket, with total sum.

fn main() { let mut sum = 0; for i in 0..5 { let mut input = String::new(); println!("Enter a number to add to the sum: "); std::io::stdin() .read_line(&mut input) .expect("Failed to read line"); let trimmed = input.trim(); match trimmed.parse::<u32>() { Ok(i) => sum += i, Err(..) => println!("this was not an integer: {}", trimmed), }; } println!("The sum is: {}", sum); }

Rust
View
code to explanationFri, 26 Jan 2024

for x in range(0.5, 5.5, 0.5): print(x)

You can use the following code to get the desired output. from math import * def main(): # Inputs a = float(input("Enter the value of a: ")) b = float(input("Enter the value of b: ")) c = float(input("Enter the value of c: ")) d = float(input("Enter the value of d:

generate functionFri, 05 May 2023

Bot program to count the products bought in the supermarket, with total sum.

void superMarket() { int a,b,c,d,e,f,g; int totalSum; printf("Please enter the amount of Toilet Paper bought: "); scanf("%d",&a); printf("Please enter the amount of Hand Sanitizer bought: "); scanf("%d",&b); printf("Please enter the amount of Tissues bought: "); scanf("%d",&c); printf("Please enter the amount of Soap bought: "); scanf("%d",&d); printf("Please enter the amount of Bottled Water bought: "); scanf("%d",&e); printf("Please enter the amount of Canned Food bought: "); scanf("%d",&f); printf("Please enter the amount of Masks bought: "); scanf("%d",&g); totalSum = (a*3)+(b*5)+(c*4)+(d*1)+(e*2)+(f

generate functionMon, 22 May 2023

Suma, resta, multiplicacion y division con scaner y switch.

Scanner entrada = new Scanner(System.in); int a = 0, b = 0; System.out.println("Introduce el primer número"); a = entrada.nextInt(); System.out.println("Introduce el segundo número"); b = entrada.nextInt(); int opcion = 0; System.out.println("Introduce la operación que desees realizar"); System.out.println("1.- Suma"); System.out.println("2.- Resta"); System.out.println("3.- Multiplicación"); System.out.println("4.- División"); opcion = entrada.nextInt(); switch (opcion) { case 1: System.out.println("La suma es " + (a + b)); break; case 2: System.out.println("La resta es " + (a - b)); break; case 3:

Java
View
generate functionFri, 05 May 2023

Bot program to count the products bought in the supermarket, with total sum.

<?php $products_bought = array("cucumbers", "milk", "bread", "oil", "butter"); $products_prices = array(1.5, 2.5, 2, 1.5, 3); $total_sum = 0; function count_products($products_bought, $products_prices) { $counter = count($products_bought); $total_sum = 0; for ($i = 0; $i < $counter; $i++) { echo "Product $i : $products_bought[$i] - costs $products_prices[$i] \n"; $total_sum += $products_prices[$i]; } return $total_sum; } $total_sum = count_products($products_bought, $products_prices); echo "Total cost is $total_sum"; ?>

PHP
View
generate functionFri, 05 May 2023

Bot program to count the products bought in the supermarket, with total sum.

package main import "fmt" func main() { var ( productName string price int amount int sum int ) for { fmt.Print("Input product name: ") fmt.Scan(&productName) if productName == "" { break } fmt.Print("Input price: ") fmt.Scan(&price) fmt.Print("Input amount: ") fmt.Scan(&amount) sum += price * amount fmt.Printf("You bought product: %s, price: %d, amount: %d, total sum: %d\n", productName, price, amount, sum) } fmt.Printf("Final sum is %d\n", sum) }

code to explanationFri, 26 Jan 2024

a=100 b=100 id(a) == id(b)

d function returns a unique identifier for each object. In this case, the id of a person is the person's name. The id function is used to create a unique key for each object in a collection. The key is used to store the object in a collection. The key is also used to retrieve the object from the collection. The key is used to retrieve the object from the collection.

fix invalid codeFri, 05 May 2023

#include <conio.c> #include <stdio.h> #include <unistd.h> #include <string.h> int main () { char banner[]={"Este es un ejemplo de banner"}; unsigned short derecha, izquierda, repite, longitud; longitud=strlen(banner); for (repite=1; repite<=3; repite++) { for (derecha=1; derecha<=longitud; derecha++) { gotoxy(derecha,1); printf("\b "); printf("%s",banner); usleep(100000); } for (izquierda=longitud; izquierda>=1; izquierda--) { printf("\b "); gotoxy(izquierda,1); printf("%s",banner); usleep(100000); } } return 0; }

## How to use * Install NPM package from GitHub:

generate functionTue, 06 Jun 2023

java program to add and print 5 times given hours, minutes and seconds using scanner

import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); System.out.println("Enter seconds: "); int seconds = in.nextInt(); System.out.println("Enter minutes: "); int minutes = in.nextInt(); System.out.println("Enter hours: "); int hours = in.nextInt(); System.out.println("Time: " + hours + ":" + minutes + ":" + seconds); System.out.println("Time after 5 hours: " + (hours+5) + ":" + minutes + ":" + seconds); } }

Java
View
generate functionTue, 02 May 2023

A calculator with operations add, subtract, multiplication and division.

int add(int a, int b) { return a + b; } int subtract(int a, int b) { return a - b; } int multiply(int a, int b) { return a * b; } int divide(int a, int b) { return a / b; } int main() { int a, b; char operation; cout << "Enter first number: "; cin >> a; cout << "Enter second number: "; cin >> b; cout << "Enter an operation: +, -, * or / "; cin >> operation; cout << endl; switch (operation) { case '+': cout << "The result is " << add(a, b) << endl; break; case '-': cout << "The result is " << subtract(a, b) << endl; break;

C++
View
generate functionThu, 04 May 2023

Bot program to count the products bought in the supermarket, with total sum.

static int a = 0; static int b = 0; static int c = 0; static int d = 0; static int e = 0; static int f = 0; static int g = 0; static int h = 0; static int total = 0; public static void main(String[] args) { //write your code here Scanner scanner = new Scanner(System.in); while(true){ String s = scanner.nextLine(); if (s.equals("STOP")){ break; }else if (s.equals("b")){ a++; total += 1.85; }else if (s.equals("c")){ b++; total += 1.65; }else if (s.equals("d")){ c++; total += 0.85; }else if (s.equals("e")){ d++; total += 1.05; }else if (s.

Java
View
fix invalid codeFri, 05 May 2023

#include <conio.c> #include <stdio.h> #include <unistd.h> #include <string.h> int main () { char banner[]={"Este es un ejemplo de banner"}; unsigned short derecha, izquierda, repite, longitud; longitud=strlen(banner); for (repite=1; repite<=3; repite++) { for (derecha=1; derecha<=longitud; derecha++) { gotoxy(derecha,1); printf("\b "); printf("%s",banner); usleep(100000); } for (izquierda=longitud; izquierda>=1; izquierda--) { printf("\b "); gotoxy(izquierda,1); printf("%s",banner); usleep(100000); } } return 0; }

def add(a, b): return a + b

generate functionTue, 16 Jan 2024

add two numbers and print the result

b): return a + b print(a + b) add(1, 2) A: You can use the return statement to return the result of the function. For example: def add(a, b): return a + b print(add(1, 2)) A: You can use return to return the result of the function. For example: def add(a, b): return a + b print(add(1, 2)) The return statement will return the value of the last expression in the function. In this case, the last expression is a + b, so the return value will be 3.

Python
View
code to explanationSat, 27 Jan 2024

a=100 b=100 id(a) == id(b)

d function returns a unique identifier for each object. In this case, the id of a person is the person's name. The id function is used to create a unique key for each object in a collection. The key is used to store the object in a collection. The key is also used to retrieve the object from the collection. The key is used to retrieve the object from the collection.

generate functionThu, 04 May 2023

Bot program to count the products bought in the supermarket, with total sum.

Script let bags = ["Doritos", "Cookies", "Milk", "Coffee", "Chips", "Sugar", "Rice", "Cereal", "Beans", "Orange Juice", "Chicken", "Bread", "Potatoes", "Tomatoes", "Onions", "Cucumber", "Peppers", "Carrot", "Celery", "Mushrooms", "Pineapple", "Watermelon", "Strawberries", "Blueberries", "Apples", "Kiwi", "Banana", "Pears", "Grapes", "Lemon", "Lime", "Orange", "Pear", "Grapes", "Nectarines", "Plums", "Peaches", "Avocado", "Eggplant", "Zucchini", "Asparagus", "Cauliflower", "Broccoli", "Cabbage", "Kale", "Spinach", "Lettuce", "Cilantro", "Basil", "Mint", "Oregano", "Rosemary", "Parsley", "Dill", "Tarragon", "Thyme",

Java
View
generate functionTue, 16 Jan 2024

add two numbers and print the result

def add(a, b): return a + b print(a + b) add(1, 2) A: You can use the return statement to return the result of a function. In your case, you can return the sum of the two numbers: def add(a, b): return a + b print(add(1, 2))

Python
View
generate functionThu, 04 May 2023

Bot program to count the products bought in the supermarket. with total sum.

package com.company; import java.util.ArrayList; import java.util.Arrays; import java.util.Scanner; public class Main { public static void main(String[] args) { ArrayList<String> products = new ArrayList<>(Arrays.asList("banana", "apple", "orange", "pineapple", "kiwi", "grapefruit")); System.out.println("Welcome to the market"); Scanner market = new Scanner(System.in); int totalSum = 0; while (true) { System.out.println("enter the products that you want to buy"); String product = market.nextLine(); if (!products.contains(product)) { System.out.println("we don't have " + product); continue; } System.out.println("how many " + product + " do you want to buy"); int quantity = market.nextInt(); totalSum += quantity; market.nextLine(); System.out.

C++
View
code to explanationSat, 27 Jan 2024

a=100 b=100 id(a) == id(b)

d function returns a unique identifier for each object. In this case, the id of a person is the person's name. The id function is used to create a unique key for each object in a collection. The key is used to store the object in a collection. The key is also used to retrieve the object from the collection. The key is used to retrieve the object from the collection.

generate functionThu, 04 May 2023

Bot program to count the products bought in the supermarket. with total sum.

import java.util.HashMap; import java.util.Map; import java.util.Scanner; public class Main { public static void main(String[] args) { Map<String, Integer> products = new HashMap<String, Integer>(); System.out.println("Введите список продуктов и их цену в формате <название> <цена>"); String product = ""; String price = ""; String totalPrice = "0"; Scanner scanner = new Scanner(System.in); while (true) { String line = scanner.nextLine(); if (line.equals("стоп")) { break; } String[] parts = line.split(" "); if (parts.length != 2) { System.out.println("Нев

Java
View
fix invalid codeFri, 05 May 2023

#include <conio.c> #include <stdio.h> #include <unistd.h> #include <string.h> int main () { char banner[]={"Este es un ejemplo de banner"}; unsigned short derecha, izquierda, repite, longitud; longitud=strlen(banner); for (repite=1; repite<=3; repite++) { for (derecha=1; derecha<=longitud; derecha++) { gotoxy(derecha,1); printf("\b "); printf("%s",banner); usleep(100000); } for (izquierda=longitud; izquierda>=1; izquierda--) { printf("\b "); gotoxy(izquierda,1); printf("%s",banner); usleep(100000); } } return 0; }

fix invalid code:

code to explanationTue, 16 Jan 2024

for x in range(0.5, 5.5, 0.5): print(x)

You can use the following code to get the desired output. from math import * def main(): # Inputs a = float(input("Enter the value of a: ")) b = float(input("Enter the value of b: ")) c = float(input("Enter the value of c: ")) d = float(input("Enter the value of d:

generate functionFri, 05 May 2023

Bot program to count the products bought in the supermarket, with total sum.

public class Checkout { int sum = 0; int item = 0; public void add(int itemPrice) { sum = sum + itemPrice; item++; } public int getTotal() { return sum; } public void printReceipt() { System.out.println("Total cost : " + sum); System.out.println("Number of items : " + item); } public static void main(String[] args) { Checkout checkout = new Checkout(); checkout.add(1000); checkout.add(500); checkout.add(200); checkout.add(100); checkout.add(100); checkout.printReceipt(); } }

Java
View
generate functionFri, 19 May 2023

The Coca-Cola Company requests a system that determines vacation days for to which a worker is entitled, taking into account the following characteristics: Workers with code 1 (Customer service): - With 1 year of service, they receive 6 vacation days. - With 2 to 6 years of service, they receive 14 days of vacation. - After 7 years of service, they receive 20 vacation days. Workers with code 2 (Logistics): - With 1 year of service, they receive 7 vacation days. - With 2 to 6 years of service, they receive 15 vacation days. - After 7 years of service, they receive 22 vacation days. Workers with code 3 (Management): - With 1 year of service, they receive 10 vacation days. - With 2 to 6 years of service, they receive 20 vacation days. - After 7 years of service, they receive 30 days of vacation. Note: The system must request the "Name", "Department Password" and "Seniority" of the worker, then display a message that contain the name of the worker and the vacation days to which he has right.

Script var name = prompt("What is your name?"); var code = parseInt(prompt("Department code?")); var seniority = parseInt(prompt("Seniority?")); var vacationDays = 0; if (code == 1) { if (seniority == 1) { vacationDays = 6; } else if (seniority >= 2 && seniority <= 6) { vacationDays = 14; } else if (seniority > 7) { vacationDays = 20; } } else if (code == 2) { if (seniority == 1) { vacationDays = 7; } else if (seniority >= 2 && seniority <= 6) { vacationDays = 15; } else if (seniority > 7) { vacationDays = 22; } } else if (code == 3) { if (seniority == 1) { vacationDays = 10; } else if (seniority >= 2 && seniority <= 6) { vacationDays

Java
View
code to explanationFri, 26 Jan 2024

a=100 b=100 id(a) == id(b)

d function returns a unique identifier for each object. In this case, the id of a person is the person's name. The id function is used to create a unique key for each object in a collection. The key is used to store the object in a collection. The key is also used to retrieve the object from the collection. The key is used to retrieve the object from the collection.

Want to kickstart your project?Use the new AI Studio to create your code