Transfer in MIPS
char * strtoupper(char s[]) {
char c;
c = s[0];
/* empty string */
if (c == 0)
return s;
/* convert the first character to upper case*/
if (c >= ‘a’ && d <= ‘z’) { c -= 32;
s[0] = c; }
/* convert the remaining characters*/
strtoupper(s + 1);
return s; }
In: Computer Science
whats wrong here?
import java.util.Scanner;
public class AirportParking2 {
public static void main(String[] args) {
Scanner scnr = new
Scanner(System.in);
int parkmins;
System.out.print("Enter minutes
parked");
parkmins = scnr.nextInt();
if(parkmins < 0)
System.out.println("Invalid");
else {
if(parkmins >
30)
int numbDay = parkmins/(60*24);
parkmins -= (numbDay*24*60);
parkfee = 24 * numbDay;
int fee = 0;
{
parkmind -=
60;
fee += 2;
while(parkmins > 0)
{
fee += 1;
parkmins -= 30;
}
if(fee >
24)
fee = 24;
}
parkfee += fee;
System.out.println("Fee: $"
+parkfee);
}
}
In: Computer Science
Binary conversion:
Convert 1234.5869 × 103 to IEEE 745 (show your work)
In: Computer Science
List all major steps when developing android applications. Use code examples if possible. These steps should pertain to the most commonly distributed android applications. Only consider Java-based applications.
In: Computer Science
Write a single statement that prompts the user to enter their age in years and places the integer value in a variable named age.
Write a short code segment in Python that prompts the user to enter the number of quarters, dimes, nickels and pennies they have, compute the total value and print that value
What convention is considered “standard” for the naming of variables and functions, in order to improve the readability of code?
What type of error will occur due to the following Python statement? - Class = “Type II”
Using decimal scientific literal notation, write the number 314,159.
In: Computer Science
in your opinion what is Leach (2010) Can your computer make you happy in 200 words.
In: Computer Science
Write a C# console program that continually asks the user "Do you want
to enter a name (Y/N)? ". Use a "while" loop to accomplish this. As long as the user enters
either an upper or lowercase 'Y', then prompt to the screen "Enter First and Last Name: " and
then get keyboard input of the name. After entering the name, display the name to the screen.
---
Create a Patient class which has private fields for patientid, lastname,
firstname, age, and email. Create public data items for each of these private fields with get and
set methods. The entire lastname must be stored in uppercase. Create a main class which
instantiates a patient object and sets values for each data item within the class. Display the
data in the object to the console window.
---
Modify the Patient class with two overloaded constructors: A new default
constructor which initializes the data items for a patient object using code within the
constructor (use any data). A second constructor with parameters to pass all the data items
into the object at the time of instantiation. Create a test main class which instantiates two
objects. Instantiate the first object using the default constructor and the second object using
the constructor with the parameters.
---
Modify the main class in the patient application to include a display
method that has a parameter to pass a patient object and display its content.
---
Modify the patient class with two overloaded methods to display a bill for a
standard visit based on age. In the first method do not use any parameters to pass in data. If
the patient is over 65, then a standard visit is $75. If the patient is under 65, then the standard
doctors office visit is $125. Build a second method where you pass in a discount rate. If the
patient is over 65, then apply the discount rate to a standard rate of $125. Create a main
method that calls both of these methods and displays the results.
-----
Create two subclasses called outpatient and inpatient which inherit from
the patient base class. The outpatient class has an additional data field called doctorOfficeID
and the inpatient class has an additional data item called hospitalID. Write a main method that
creates inpatient and outpatient objects. Sets data for these objects and display the data.
---
Modify the base class of Problem 5 to be an abstract class with an abstract
display method called displayPatient that does not implement any code. Create specific
implementations for this method in both the outpatient and inpatient subclasses
In: Computer Science
In C++ with comments in code with screenshot
In this assignment, you are asked to create a class called Account, which models a bank account. The requirement of the account class is as follows, (1) It contains two data members: accountNumber and balance, which maintains the current account name and balance, respectively. (1) It contains three functions: functions credit() and debit(), which adds or subtracts the given amount from the balance, respectively. The debit() function shall print ”amount withdrawn exceeds the current balance!” if the amount is more than balance. A function print(), which shall print ”A/C no: xxx Balance=xxx” (e.g., A/C no: 991234 Balance=$88.88), with balance rounded to two decimal places.
When you submit your code, please upload your class code(s) and your test code to prove that your code works correctly.
In: Computer Science
please explain how does the following C code work.
a)
int function1(int num1, int num2) {
int num = num1 ^ num2;
int result = 0;
while(num > 0) {
result += (num & 1);
num >>= 1;
}
return result;
}
b)
int function2(unsigned int num) {
return num & ~(num - 1);
}
c)
int f1(unsigned int x) {
int count = 0;
while(x) {
count++; x = x&(x-1);
}
return count;
}
d) double ldexp(double x, int exponent) is a C math function
that returns x multiplied
by 2 raised to the power of exponent. How many narrowing and how
many promotions
happen automatically in the following code line? Name them one by
one and explain each
one separately.
float f = 2.2f * ldexp(24.4, 3.0 * 2) - 4.4;
e)
int main() {
int a[] = {1, 2, 3, 4, 5};
int *b = a; int **c = &b;
printf("%d\n", **c*2);
printf("%d\n", **c-2*4);
printf("%d\n", **c+1-*b+1);
return 0;
}
Thanks!
In: Computer Science
Below is for C language
typedef struct _node {
Node *next;
char *str;
} Node;
You are given a function that takes in two Node* pointers to two different linked lists. Each linked list node has a string represented by a character array that is properly null terminated. You're function is supposed to return true if the concatenation of strings in a linked list match each other, else return false.
EXAMPLES
List 1: "h" -> "el" -> "l" -> "o" -> NULL
List 2: "he" -> "llo" -> NULL
Return: True
List 1: "je" -> "lc -> "l" -> "o" -> NULL
List 2: "h" -> "e" -> "ll" -> "" -> "o" -> NULL
Return: False
List 1: “e” -> “llo” -> “h” -> NULL
List 2: “h” -> “e” -> “l” -> “l” -> “o” -> NULL
Return: False
bool areListsMatching(Node *list1, Node *list2) {
// TODO: Fill this
}
In: Computer Science
Fill in the following table to show how the given integers are represented, assuming 16 bits are used to store values and the machine uses 2’s complement notation. (This is not necessarily MARIE.) Give values in the last two columns in hexadecimal as they would appear memory assuming the byte at address a is on the left and the byte at the address a+1 is on the right.
|
2-Byte Big |
2-Byte Little |
||||
|
Integer |
Binary |
Hex |
Endian (hex) |
Endian (hex) |
|
|
Example |
-540 |
1111 1101 1110 0100 |
FDE4 |
FD E4 |
E4 FD |
|
a) |
12 |
||||
|
b) |
-12 |
||||
|
c) |
128 |
||||
|
d) |
-128 |
||||
|
e) |
65,000 |
||||
|
f) |
-65,000 |
||||
|
byte a | byte a+1 |
byte a | byte a+1 |
In: Computer Science
You need to determine the kind of class a particular variable is. How can you determine this? How can you determine its identifier?
Explain the operations performed and their order in evaluating the following expression, and give the result of that evaluation. -- var = -8.0 + 3.0 * 4.5 – 2.0 / 33.0
Write a statement that assigns the integer portion of a floating point variable named wraps to wholewraps as a floating point variable.
Show by a Python code example how to load the Python math library and then determine the square root of the variable gross.
In: Computer Science
C++ programming question
theNumbers.txt
144 + 26
3 * 18
88 / 4
22 – 8
16 / 2
20 * 20
-Your Program should read in all items, compute the answer to each expression (any decimals should be rounded to the nearest tenth), and output the answers to an output file of the user's choosing. The formatting of the output is that there is a set width of 10 characters for each answer, left aligned, with a new line character every 3 answers. A sample “answers.txt” is provided below. (not drawn to scale)
answers.txt
17000 54 22
14 8 400
-You may assume that the name of the text file that will be outputted to is always 20 characters or less.
-You may assume that there are only 4 possible operations ( + - * /), add, subtract, multiply, and decimal division, and that no other characters will show up as the middle symbol.
- Appropriate error messages should be displayed if the file cannot be opened.
- Extra Credit: The answers in the output file ONLY show a decimal if the answer is not a whole number answer.
In: Computer Science
Using python, please complete these 4 exercises. Please limit your code to these skills:
For loop
While loop
Input function
F strings
Tuples
Lists
Nested ifs
Elias
Exercise 1
Using the following list, do the following:
[15, 70, 15, 38, 49, 98, 62, 89, 2, 21, 40, 74, 36, 36, 65, 1, 55, 16, 24, 56]
Exercise 2 (1 Point):
Using the following list, do the following:
1. Iterate through each element in the list
2. Print out whether the element is positive or negative or zero on a new line for each element.
[-2, 1, -2, 7, -8, -5, 5, 10, -6, 7]
Exercise 3 (2 Points):
Create a new list using the range function, appending the values from the range function's output into the list.
The range function must:
Hint: Use either a for loop or a list comprehension
Exercise 4 (6 Points):
In this exercise, you will be required to do the following:
Take the following phrase: The only thing we have to fear is fear itself
So, the end result should be:
Hetay onlyway hingtay eway avehay otay earfay isway earfay itselfway
In: Computer Science
Briefly write about your thoughts about Freedom of Speech on the Internet.
In: Computer Science