Saturday, December 12, 2020

#597 Consider the relations Student sid name age gender

Consider the relations Student sid name age gender - Computer Science

ChemistryExplain daily providing Q&A content “#597 Consider the relations Student sid name age gender" in Computer science, Ba computer science, Berkeley computer science, a Computer science associate degree jobs

ChemistryExplain “#597 Consider the relations Student sid name age gender" in Computer science, Ba computer science, Berkeley computer science, Computer science associate degree jobs
Get the Free Online Chemistry Q&A Questions And Answers with explain. To crack any examinations and Interview tests these Chemistry Questions And Answers are very useful. Here we have uploaded the Free Online Chemistry Questions. Here we are also given the all chemistry topic.

 ChemistryExplain team has covered all Topics related to inorganic, organic, physical chemistry, and others So, Prepare these Chemistry Questions and Answers with Explanation Pdf.

For More Chegg Questions

Join Our Telegram Channel for Covers All Update by ChemistryExplain:- Click Now

Free Chegg Question

Consider the relations Student(sid, name, age, gender, address, fee, sem_Id) and Semester (sem_Id, date). Write relational algebra expressions for the following:

  1. Get all the students from the Student
  2. Select all the female students from the Student
  3. Find all students whose age is greater than 20
  4. Count all the students less than 20 years
  5. Find all students whose name starts with ‘A’
  6. Find the average age of the students.
  7. Find the total sum of the fee.
  8. Find the maximum age of students.
  9. Find all the details of students whose age is maximum.
  10. Find all students whose age lies between 20 and 25.
  11. Find the name of the student who lives in Liaquat-e-bad.
  12. Display the list of all the students along with semester details.
  13. Find the youngest student in the class.
  14. Retrieve the details of the semester in which there are more than two students.
  15. Retrieve the details of all the students along with the semester. If a student is not enrolled in a semester, the details of the students should be displayed.
  16. Retrieve the details of all the semesters along with enrolled students. If a semester has no enrolled students, the details of the semester should be displayed.
  17. Retrieve the details of students with semester irrespective of if the students are enrolled in a semester or if a semester has any students or not.
  18. Find the names of students who are younger than ‘Saleem’
  19. Find the students who are neighbors of ‘Kaleem’.
  20. Find the names of all students who are older than the average age of students.
  21. Find the details of all students who are in semester 1.

Free Chegg AnswerFor More Chemistry Notes and Helpful Content Subscribe Our YouTube Chanel - Chemistry Explain  

Free Chegg Answer

At 1st you must know in algebra relationship we have:-

Projection (π)
Projection is used to project required column data from a relation.

Selection (σ)
Selection is used to select the required tuples of the relations.

Cross Product (X)

Cross product between two relations let's say A and B, so cross product between A X B will result in all the attributes of A followed by each attribute of B. Each record of A will pair with every record of B.

Natural Join (⋈)

Natural join is a binary operator. Natural join between two or more relations will result set of all combinations of tuples where they have equal common attributes.

Now let's move to answers of the questions:-

Ans.1> π name(Student).

Explanation:- Here all student names will be projected.

Ans.2> π name(σ gender= female ( Student))

Explanation:- Here only female student names will be shown.

Ans.3> π name(σ age>20(Student))

Explanation:- Here all student names will be shown, whose age is greater than 20.

Ans.4>π name( σ age<20(name G count(age)(Student)))

explanation:- Here number of name count will be displayed.

Ans.5>  σ age(age G avg(age)(student)).

Explanation:- Here average age will be displayed.

Labels: , ,

Thursday, December 10, 2020

#594 Identify Inheritance, Rewrite the code that

Identify Inheritance, Rewrite the code that - Computer Science

ChemistryExplain daily providing Q&A content “#594 Identify Inheritance, Rewrite the code that" in Computer science, Ba computer science, Berkeley computer science, Computer science associate degree jobs

ChemistryExplain “#594 Identify Inheritance, Rewrite the code that in Computer science, Ba computer science, Berkeley computer science, Computer science
Get the Free Online Chemistry Q&A Questions And Answers with explain. To crack any examinations and Interview tests these Chemistry Questions And Answers are very useful. Here we have uploaded the Free Online Chemistry Questions. Here we are also given the all chemistry topic.

 ChemistryExplain team has covered all Topics related to inorganic, organic, physical chemistry, and others So, Prepare these Chemistry Questions and Answers with Explanation Pdf.

For More Chegg Questions

Join Our Telegram Channel for Covers All Update by ChemistryExplain:- Click Now

Free Chegg Question

ChemistryExplain “#594 Identify Inheritance, Rewrite the code that in Computer science, Ba computer science, Berkeley computer science, Computer science

ChemistryExplain “#594 Identify Inheritance, Rewrite the code that in Computer science, Ba computer science, Berkeley computer science, Computer science

ChemistryExplain “#594 Identify Inheritance, Rewrite the code that in Computer science, Ba computer science, Berkeley computer science, Computer science

ChemistryExplain “#594 Identify Inheritance, Rewrite the code that in Computer science, Ba computer science, Berkeley computer science, Computer science

ChemistryExplain “#594 Identify Inheritance, Rewrite the code that in Computer science, Ba computer science, Berkeley computer science, Computer science

ChemistryExplain “#594 Identify Inheritance, Rewrite the code that in Computer science, Ba computer science, Berkeley computer science, Computer science
Based on the codes:
1. Identify Inheritance, Rewrite the code that has the Inheritance concept, and explain why do you identify it as Inheritance.
 
2. Identify Abstraction. Rewrite the code that has the Abstraction concept and explain why do you identify it as Abstraction.
 
3. Identify Encapsulation. Rewrite the code that has the Encapsulation concept and explain why do you identify it as Encapsulation.
 
4. Identify Polymorphism. Rewrite the code that has the Polymorphism concept and explain why do you identify it as Polymorphism.
 
5. What is the basic programming concept such as loop and selection that has been used? Rewrite the code and explain

Free Chegg AnswerFor More Chemistry Notes and Helpful Content Subscribe Our YouTube Chanel - Chemistry Explain  

Free Chegg Answer

Ques 1)The examples of inheritance in the given code are:

class MyButton extends JButton{
.....
.........
.........
}
since there is a keyword extends which means class MyButton
has all methods and attribute which JButton class have, along
with this MyButton can implement its own functionality too.
next example is
public class PuzzleEx extends JFrame{

.........
.............
}
private class ClickAction extends AbstractAction{
..............
}

Inheritance gives us the advantage of code reusability and readability. All class mentioned above are child class and they inherit the properities and functionality of parent class, we need not write the same code again in child class. This makes it easier to reuse the code, makes us write less code and the code became much more readable.


Labels: , ,

Friday, December 4, 2020

#573 Read the above scenario, which describes the data

Read the above scenario, which describes the data - Computer Science

ChemistryExplain daily providing Q&A content “#573 Read the above scenario, which describes the data" in Computer science, Ba computer science, Berkeley computer science, Computer science associate degree jobs

ChemistryExplain “#573 Read the above scenario, which describes the data in Computer science, Ba computer science, Berkeley computer science

Get the Free Online Chemistry Q&A Questions And Answers with explain. To crack any examinations and Interview tests these Chemistry Questions And Answers are very useful. Here we have uploaded the Free Online Chemistry Questions. Here we are also given the all chemistry topic.

 ChemistryExplain team has covered all Topics related to inorganic, organic, physical chemistry, and others So, Prepare these Chemistry Questions and Answers with Explanation Pdf.

For More Chegg Questions

Join Our Telegram Channel for Covers All Update by ChemistryExplain:- Click Now

Free Chegg Question

Read the above scenario, which describes the data requirements of fault management system. 

(a) Identify the main entity types in given scenario.

(b) Identify the main relationship types between the entity types described in (a) and represent each relationship as an ER diagram.

(c) Determine the multiplicity constraints for each relationships described in (b).

(d) Determine candidate and primary key attributes for each (strong) entity type.

(e) Using your answers (a) to (d) attempt to represent the data requirements of the fault management systemas a single ER diagram.

(f) Implement the above schema in one of the RDBMSs (in form of tables) you currently using.

Write relational algebra expression and SQL statements for the following:

i. Find all the faults with fault description

ii. Find the description of all the faults occurred during Jan 2020-Dec 2020

iii. Find the name of the faults assigned to Aslam

iv. Group all the faults based on type, find their count and the average age of the technician managing it

v. Find all the faults that are not assigned to any technician

vi. Find the technician who has not been assigned any fault

vii. Find all the faults that ends with dead

viii. Find the oldest technician

ix. Find the youngest technician

x. Find the second oldest technician

xi. Find the type of the fault which has not occurred so far

xii. Find the number of faults assigned to each technician

xiii. Find the number of faults occurred in every month of the year 2020

xiv. Find all the technicians who has not been assigned more than two faults

xv. Find all the faults, their type, assigned date, the technician details. Sort the faults based on assigned date

Free Chegg AnswerFor More Chemistry Notes and Helpful Content Subscribe Our YouTube Chanel - Chemistry Explain  

Free Chegg Answer

Write relational algebra expression and SQL statements for the following:

1).SELECT fault_type,fault_description FROM Fault;

πfault_type,fault_description(Fault);

2).SELECT FaultType.fault_description FROM Fault INNER JOIN FaultType ON Fault.fault_id=FaultType.fault_id WHERE YEAR(Fault.fault_date)=2020;

πFaultType.fault_description(σYEAR(Fault.fault_date)=2020(Fault X FaultType));

3).SELECT Fault.fault_type FROM Fault INNER JOIN FaultManagement ON Fault.fault_id=FaultManagement.Fault_id INNER JOIN Technician ON FaultManagement.technician_id=Technician.technician_id WHERE Technician.name="Aslam";

πFault.fault_type(σTechnician.name="Aslam"( Fault X FaultManagement X Technician))

4).SELECT COUNT(Fault.Fault_id),AVG(Technician.age) FROM Fault INNER JOIN FaultManagement ON Fault.fault_id=FaultManagement.Fault_id INNER JOIN Technician ON FaultManagement.technician_id=Technician.technician_id GROUP BY Fault.Fault_type;

πCOUNT(Fault.fault_id),AVG(Technician.age) ((σTechnician.name="x"( Fault X FaultManagement X Technician));

Explaination for SQL:

SELECT statement is used for output of that column, FROM is used for selecting the tables from which we want output,INNER JOIN is used for join operation on tables with specified columns using ON.WHERE is used to apply condition for output.COUNT() ,AVG() are aggregate functions in SQL where COUNT() is used to count the tuples of result and AVG() is used to find average of given column values.GROUP BY statement groups the result on specified column.Here,group By is used on Fault_type.

Explaination for Relational Algebra:

π is used to output the specified columns.σ is used for conditions . X is used for join operation in relational algebra.AVG() and COUNT() are aggregate functions and work as they work in mathematics.

Labels: , ,

Friday, November 27, 2020

#537 Write relational algebra expression and SQL statements

Write relational algebra expression and SQL statements - Computer Science

ChemistryExplain daily providing Q&A content “#537 Write relational algebra expression and SQL statements" in Computer science, Ba computer science, Berkeley computer science, a Computer science associate degree jobs

ChemistryExplain “#537 Write relational algebra expression and SQL statements in Computer science, Ba computer science, Berkeley computer science
Get the Free Online Chemistry Q&A Questions And Answers with explain. To crack any examinations and Interview tests these Chemistry Questions And Answers are very useful. Here we have uploaded the Free Online Chemistry Questions. Here we are also given the all chemistry topic.

 ChemistryExplain team has covered all Topics related to inorganic, organic, physical chemistry, and others So, Prepare these Chemistry Questions and Answers with Explanation Pdf.

For More Chegg Questions

Join Our Telegram Channel for Covers All Update by ChemistryExplain:- Click Now

Free Chegg Question

Consider the following scenario. You are developing a fault management system. The database maintains the following information: Fault (fault_id,fault_type, fault_date) FaultType(fault_type, fault_description) FaultManagement(fault_id,technician_id, assigned_date) Technician(technician_id, name, age) Write relational algebra expression and SQL statements for the following:

i. Find all the faults with fault description

ii. Find the description of all the faults that occurred during Jan 2020-Dec 2020

iii. Find the name of the faults assigned to Aslam

iv. Group all the faults based on type, find their count and the average age of the technician managing it

v. Find all the faults that are not assigned to any technician

vi. Find the technician who has not been assigned any fault

vii. Find all the faults that end with ‘dead’

viii. Find the oldest technician

ix. Find the youngest technician

x. Find the second oldest technician

xi. Find the type of fault which has not occurred so far

xii. Find the number of faults assigned to each technician

xiii. Find the number of faults that occurred in every month of the year 2020

xiv. Find all the technicians who have not been assigned more than two faults

xv. Find all the faults, their type, assigned date, the technician details. Sort the faults based on the assigned date

//-----------------------------------------------------------------------------//
Only required an answer to question no.2

Question-2 marks [06] Read the above scenario, which describes the data requirements of the fault management system.

(a) Identify the main entity types in the given scenario.

(b) Identify the main relationship types between the entity types described in (a) and represent each relationship as an ER diagram.

(c) Determine the multiplicity constraints for each relationship described in (b).

(d) Determine candidate and primary key attributes for each (strong) entity type.

(e) Using your answers (a) to (d) attempt to represent the data requirements of the fault management system as a single ER diagram.

(f) Implement the above schema in one of the RDBMSs (in form of tables) you currently using.

Note: I just required an answer of question no.2 only. The reason of copying question no.1 is because the scenario is in question no.1.

Question-3 marks [04] Consider whether it is appropriate to introduce introduce the enhanced concepts of specialization/generalization, aggregation, and/or composition into the ER model for the case study described in question 1. If appropriate, redraw the ER diagram as an EER diagram with the additional enhanced concepts

Free Chegg AnswerFor More Chemistry Notes and Helpful Content Subscribe Our YouTube Chanel - Chemistry Explain  

Free Chegg Answer

The EER diagram is posted below with the concept of specialization.

ChemistryExplain “#537 Write relational algebra expression and SQL statements in Computer science, Ba computer science, Berkeley computer science

Labels: , ,

Thursday, November 26, 2020

#536 Consider the following scenario you are developing

Consider the following scenario you are developing - Computer Science

ChemistryExplain daily providing Q&A content “#536 Consider the following scenario you are developing" in Computer science, Ba computer science, Berkeley computer science, Computer science associate degree jobs

ChemistryExplain “#536 Consider the following scenario you are developing" in Computer science, Ba computer science, Berkeley computer science
Get the Free Online Chemistry Q&A Questions And Answers with explain. To crack any examinations and Interview tests these Chemistry Questions And Answers are very useful. Here we have uploaded the Free Online Chemistry Questions. Here we are also given the all chemistry topic.

 ChemistryExplain team has covered all Topics related to inorganic, organic, physical chemistry, and others So, Prepare these Chemistry Questions and Answers with Explanation Pdf.

For More Chegg Questions

Join Our Telegram Channel for Covers All Update by ChemistryExplain:- Click Now

Free Chegg Question

Consider the following scenario. You are developing a fault management system. The database maintains the following information: Fault (fault_id,fault_type, fault_date) FaultType(fault_type, fault_description) FaultManagement(fault_id,technician_id, assigned_date) Technician(technician_id, name, age) Write relational algebra expression and SQL statements for the following:

i. Find all the faults with fault description

ii. Find the description of all the faults that occurred during Jan 2020-Dec 2020

iii. Find the name of the faults assigned to Aslam

iv. Group all the faults based on type, find their count and the average age of the technician managing it

v. Find all the faults that are not assigned to any technician

vi. Find the technician who has not been assigned any fault

vii. Find all the faults that end with ‘dead’

viii. Find the oldest technician

ix. Find the youngest technician

x. Find the second oldest technician

xi. Find the type of fault which has not occurred so far

xii. Find the number of faults assigned to each technician

xiii. Find the number of faults that occurred in every month of the year 2020

xiv. Find all the technicians who have not been assigned more than two faults

xv. Find all the faults, their type, assigned date, the technician details. Sort the faults based on the assigned date

//-----------------------------------------------------------------------------//
Only required an answer to question no.2

Question-2 marks [06] Read the above scenario, which describes the data requirements of the fault management system.

(a) Identify the main entity types in the given scenario.

(b) Identify the main relationship types between the entity types described in (a) and represent each relationship as an ER diagram.

(c) Determine the multiplicity constraints for each relationship described in (b).

(d) Determine candidate and primary key attributes for each (strong) entity type.

(e) Using your answers (a) to (d) attempt to represent the data requirements of the fault management system as a single ER diagram.

(f) Implement the above schema in one of the RDBMSs (in form of tables) you currently using.

Note: I just required an answer of question no.2 only. The reason of copying question no.1 is because the scenario is in question no.1.

Free Chegg AnswerFor More Chemistry Notes and Helpful Content Subscribe Our YouTube Chanel - Chemistry Explain  

Free Chegg Answer

SOLUTION IN BOTH SQL AND RELATIONAL ALGEBRA:

As you have posted multiple questions, I'm going to answer only first four sub part of the question first as per Chegg qna policy

Answering more than one question will result in the revocation of an expert's account.

It has also been informed to students to post a single question at a time.

Post the next question separately,and love to answer.

IN SQL:

1).SELECT fault_type,fault_description FROM Fault;

2).SELECT FaultType.fault_description FROM Fault INNER JOIN FaultType ON Fault.fault_id=FaultType.fault_id WHERE YEAR(Fault.fault_date)=2020;


3).SELECT Fault.fault_type FROM Fault INNER JOIN FaultManagement ON Fault.fault_id=FaultManagement.Fault_id INNER JOIN Technician ON FaultManagement.technician_id=Technician.technician_id WHERE Technician.name="Aslam";


4).SELECT COUNT(Fault.Fault_id),AVG(Technician.age) FROM Fault INNER JOIN FaultManagement ON Fault.fault_id=FaultManagement.Fault_id INNER JOIN Technician ON FaultManagement.technician_id=Technician.technician_id GROUP BY Fault.Fault_type;


IN RELATIONAL ALGEBRA:


1) πfault_type,fault_description(Fault);

2) πFaultType.fault_description(σYEAR(Fault.fault_date)=2020(Fault X FaultType));

3) πFault.fault_type(σTechnician.name="Aslam"( Fault X FaultManagement X Technician))

4) πCOUNT(Fault.fault_id),AVG(Technician.age) ((σTechnician.name="x"( Fault X FaultManagement X Technician));

Labels: , ,

Monday, November 23, 2020

#518 Write a MIPS assembly language program that

Write a MIPS assembly language program that - Computer Science

ChemistryExplain daily providing Q&A content “#518 Write a MIPS assembly language program that" in Computer science, Ba computer science, Berkeley computer science, Computer science associate degree jobs

ChemistryExplain “#518 Write a MIPS assembly language program that in Computer science, Ba computer science, Berkeley computer science
Get the Free Online Chemistry Q&A Questions And Answers with explain. To crack any examinations and Interview tests these Chemistry Questions And Answers are very useful. Here we have uploaded the Free Online Chemistry Questions. Here we are also given the all chemistry topic.

 ChemistryExplain team has covered all Topics related to inorganic, organic, physical chemistry, and others So, Prepare these Chemistry Questions and Answers with Explanation Pdf.

For More Chegg Questions

Join Our Telegram Channel for Covers All Update by ChemistryExplain:- Click Now

Free Chegg Question

Write a MIPS assembly language program that asks the user to enter an integer and then display the hexadecimal representation of that integer. 

Free Chegg AnswerFor More Chemistry Notes and Helpful Content Subscribe Our YouTube Chanel - Chemistry Explain  

Free Chegg Answer

ChemistryExplain “#518 Write a MIPS assembly language program that in Computer science, Ba computer science, Berkeley computer science

Labels: , ,

Friday, November 20, 2020

#501 Caesar's Code is a basic encryption algorithm

Caesar's Code is a basic encryption algorithm - Computer Science

ChemistryExplain daily providing Q&A content “#501 Caesar's Code is a basic encryption algorithm" in Computer science, Ba computer science, Berkeley computer science, Computer science associate degree jobs

ChemistryExplain “#501 Caesar's Code is a basic encryption algorithm in Computer science, Ba computer science, Berkeley computer science
Get the Free Online Chemistry Q&A Questions And Answers with explain. To crack any examinations and Interview tests these Chemistry Questions And Answers are very useful. Here we have uploaded the Free Online Chemistry Questions. Here we are also given the all chemistry topic.

 ChemistryExplain team has covered all Topics related to inorganic, organic, physical chemistry, and others So, Prepare these Chemistry Questions and Answers with Explanation Pdf.

For More Chegg Questions

Join Our Telegram Channel for Covers All Update by ChemistryExplain:- Click Now

Free Chegg Question

Caesar's Code is a basic encryption algorithm. It is a substitution cipher where each letter is replaced with another letter of a fixed position (the difference between the two letters is a fixed offset). For example, if the plaintext word is (Abc) and the offset is 3, then the ciphertext is (Def). Caesar's algorithm is a simple encryption technique. You are required to implement a modified version of the algorithm described as follows: - Convert capital letters into small letters and vice versa, - Use two offsets (n1 and n2) to encrypt the letters of plaintext alternatively. Those offsets should be strictly positive and greater than 0. (keep asking users to re-enter in case of invalid input). - keep digits and symbols unchanged. Implement a method to encrypt plaintext by using the modified Caesar's algorithm and returns a ciphered text. Write a main to ask the user to enter a plaintext and valid two Integers (ni and n2). Then print the ciphered text (don't print any other text). -- You can use the console or dialogs as an application's interface.

Solve in java language ----Example: Plaintext: Hello World n15, n2 - 2 Ciphertext: MGONT DOWN

Free Chegg AnswerFor More Chemistry Notes and Helpful Content Subscribe Our YouTube Chanel - Chemistry Explain  

Free Chegg Answer

Create new class CaesorsAlgo.java in eclipse or in netbeans and paste the code given below

CaesorsAlgo.java


import java.util.Scanner;


public class CaesorsAlgo {

public static StringBuffer encrypt(String text, int n1, int n2) {
StringBuffer result = new StringBuffer();

for (int i = 0; i < text.length(); i++) {
int s = n1;//get first offset
  
//check character is Uppercase
if (Character.isUpperCase(text.charAt(i))) {
//convert uppercase to lowercase
String word = String.valueOf(text.charAt(i)).toLowerCase();
//we have to use offset alternatively
if (i % 2 == 0) {
s = n1;//if index is even then use n1
} else {
s = n2;//else use n2
}
char ch = (char) (((int) word.charAt(0)
+ s - 97) % 26 + 97);

result.append(ch);
} else {
if (i % 2 == 0) {
s = n1;
} else {
s = n2;
}
//lowercase to uppercase
String word = String.valueOf(text.charAt(i)).toUpperCase();
char ch = (char) (((int) word.charAt(0)
+ s - 65) % 26 + 65);
result.append(ch);
}
}
return result;
}

public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n1 = 0, n2 = 0;
//n1 and n2 should be positive and greater than 0
while (n1 <= 0 && n2 <= 0) {
System.out.print("Enter first offset (n1): ");
n1 = sc.nextInt();

System.out.print("Enter second offset (n2): ");
n2 = sc.nextInt();
}
System.out.print("Enter your plaintext: ");
sc.nextLine();
String str = sc.nextLine().trim();
System.out.println();
String data[] = str.split(" ");//split the message into words
System.out.println("Plaintext: "+str);
StringBuilder sb = new StringBuilder();
for (int i = 0; i < data.length; i++) {
sb.append(encrypt(data[i], 5, 2) + " ");
}
System.out.println("Ciphertext: "+sb.toString());

}
}

ChemistryExplain “#501 Caesar's Code is a basic encryption algorithm in Computer science, Ba computer science, Berkeley computer science

Labels: , ,

#497 Write a code java to do caesar's code is

Write a code java to do caesar's code is - Computer Science

ChemistryExplain daily providing Q&A content “#497 Write a code java to do caesar's code is" in Computer science, Ba computer science, Berkeley computer science, a Computer science associate degree jobs

ChemistryExplain “#497 Write a code java to do caesar's code is in Computer science, Ba computer science, Berkeley computer science
Get the Free Online Chemistry Q&A Questions And Answers with explain. To crack any examinations and Interview tests these Chemistry Questions And Answers are very useful. Here we have uploaded the Free Online Chemistry Questions. Here we are also given the all chemistry topic.

 ChemistryExplain team has covered all Topics related to inorganic, organic, physical chemistry, and others So, Prepare these Chemistry Questions and Answers with Explanation Pdf.

For More Chegg Questions

Join Our Telegram Channel for Covers All Update by ChemistryExplain:- Click Now

Free Chegg Question

write a code java to do
Caesar's Code is a basic encryption algorithm. It is a
substitution cipher where each letter is replaced with another
letter of a fixed position (the difference between the two
letters is a fixed offset). For example, if the plaintext word is
(Abc) and the offset is 3, then the ciphertext is (Def).
Caesar's algorithm is a simple encryption technique. You are
required to implement a modified version of the algorithm
described as follows:
- Convert capital letters into small letters and vice versa.
- Use two offsets (n1 and n2) to encrypt the letters of
plaintext alternatively. Those offsets should be strictly positive
and greater than 1.
- keep digits and symbols unchanged.
Implement an encryption algorithm and ask the user to enter
a plaintext and valid two integers (ni and n2). Then print the
ciphered text.
You can use the console or dialogs as an application's
interface.

Free Chegg AnswerFor More Chemistry Notes and Helpful Content Subscribe Our YouTube Chanel - Chemistry Explain  

Free Chegg Answer

import java.util.*;
public class Main
{
   public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
       System.out.print("Enter a plain text : ");
       String s=sc.nextLine();
       System.out.print("Enter the first offset : ");
       int n1=sc.nextInt();
       while(n1<=1)
       {
       System.out.print("Offset should be strictly positive and greater than 1. Please enter again : ");
       n1=sc.nextInt();
       }
       System.out.print("Enter the second offset : ");
       int n2=sc.nextInt();
       while(n2<=1)
       {
       System.out.print("Offset should be strictly positive and greater than 1. Please enter again : ");
       n2=sc.nextInt();
       }
       int l=s.length();
       int c=0;
       String a="";
       for(int i=0;i<l;i++)
       {
       char x=s.charAt(i);
       if(c%2==0)
       {
       if(Character.isUpperCase(x))
{
char ch=Character.toLowerCase(x);
ch = (char)(((int)ch + n1 - 97) % 26 + 97);
a=a+ch;
c++;
}
else if(Character.isLowerCase(x))
{
char ch=Character.toUpperCase(x);
ch = (char)(((int)ch + n1 - 65) % 26 + 65);
a=a+ch;
c++;
}
else
a=a+x;
       }
       else
       {
       if(Character.isUpperCase(x))
{
char ch=Character.toLowerCase(x);
ch = (char)(((int)ch + n2 - 97) % 26 + 97);
a=a+ch;
c++;
}
else if(Character.isLowerCase(x))
{
char ch=Character.toUpperCase(x);
ch = (char)(((int)ch + n2 - 65) % 26 + 65);
a=a+ch;
c++;
}
else
a=a+x;
       }
       }
       System.out.println("Ciphered Text : "+a);
   }
}

ChemistryExplain “#497 Write a code java to do caesar's code is in Computer science, Ba computer science, Berkeley computer science

ChemistryExplain “#497 Write a code java to do caesar's code is in Computer science, Ba computer science, Berkeley computer science

ChemistryExplain “#497 Write a code java to do caesar's code is in Computer science, Ba computer science, Berkeley computer science

Labels: , ,

Thursday, November 19, 2020

#492 Design a 16-1 MUX using any number of lower

Design a 16-1 MUX using any number of lower - Computer Science

ChemistryExplain daily providing Q&A content “#492 Design a 16-1 MUX using any number of lower " in Computer science, Ba computer science, Berkeley computer science, Computer science associate degree jobs

ChemistryExplain “#492 Design a 16-1 MUX using any number of lower  in Computer science, Ba computer science, Berkeley computer science
Get the Free Online Chemistry Q&A Questions And Answers with explain. To crack any examinations and Interview tests these Chemistry Questions And Answers are very useful. Here we have uploaded the Free Online Chemistry Questions. Here we are also given the all chemistry topic.

 ChemistryExplain team has covered all Topics related to inorganic, organic, physical chemistry, and others So, Prepare these Chemistry Questions and Answers with Explanation Pdf.

For More Chegg Questions

Free Chegg Question

Question 2. Design a 16-1 MUX using any number of lower MUXs, such as 8-1 or 4-1 only. No other gates are allowed.

Question 3. In the following circuit, all gates, including the inverter, have an inertial delay of 8 ns except for gate 3, which has a 30 ns delay.

A. Write a VHDL code that gives a dataflow description of the circuit. All delays should be inertial delays.

B. Using any VHDL simulator, simulate the circuit. (Use a View Interval of 200 ns.) Initially set A = 1, B = 1, C = 1 and D = 0, then run the simulator for 60 ns. Change B to 0, and run the simulator for 60 ns. Record the waveform.

C. Change the VHDL code of Part (A) so that the inverter has a 5 ns delay.

D. Repeat Part (B).

E. Change the VHDL code of Part (c) so that gates 4 and 5 have a transport delay rather than an inertial delay.

F. Repeat Part (B)

ChemistryExplain “#492 Design a 16-1 MUX using any number of lower  in Computer science, Ba computer science, Berkeley computer science

Free Chegg AnswerFor More Chemistry Notes and Helpful Content Subscribe Our YouTube Chanel - Chemistry Explain  

Free Chegg Answer

ChemistryExplain “#492 Design a 16-1 MUX using any number of lower  in Computer science, Ba computer science, Berkeley computer science

Labels: , ,

Tuesday, October 27, 2020

#433 Write a JAVA program to store some

Write a JAVA program to store some - Computer Science

ChemistryExplain daily providing Q&A content “#433 Write a JAVA program to store some" in Computer science, Ba computer science, Berkeley computer science, Computer science associate degree jobs

ChemistryExplain “#433 Write a JAVA program to store some in Computer science, Ba computer science, Berkeley computer science

Get the Free Online Chemistry Q&A Questions And Answers with explain. To crack any examinations and Interview tests these Chemistry Questions And Answers are very useful. Here we have uploaded the Free Online Chemistry Questions. Here we are also given the all chemistry topic.

 ChemistryExplain team has covered all Topics related to inorganic, organic, physical chemistry, and others So, Prepare these Chemistry Questions and Answers with Explanation Pdf.

For More Chegg Questions

Free Chegg Question

Write a JAVA program to store some details of pizzas (menu item number, size, base, extra cheese, extra
garlic), curries (menu item number, size, curry type) and softdrinks (menu item number, size,
flavour, bottle or can) in a single array, with the options of listing all menu items or deleting a
particular menu item.
Your program must continuously prompt the user to choose an option from a list and act on that
option, until the exit option is chosen. (See the sample output below.) If a menu item is not found,
output "Not found" instead of "Done".

You must use inheritance and polymorphism to model your Pizza, Curry and SoftDrink classes (use
those exact class names) as subclasses of the same base class, which forms the basis for the array.

Note: Be very careful to reproduce the output exactly. Copy-and-paste is highly recommended to
avoid minor typographical errors that drive you crazy when submitting online!

Sample Input/Output:
Welcome to Great International Food Court
MENU: add (P)izza, add (C)urry, add (S)oft drink, (D)elete, (L)ist,
(Q)uit
p
Enter the menu item number
123
Enter the size
12"
Enter the base
Hand-tossed
Enter extra cheese
Yes
Enter extra garlic
Yes
Done
MENU: add (P)izza, add (C)urry, add (S)oft drink, (D)elete, (L)ist, (Q)uit
c
Enter the menu item number
456
Enter the size
Large
Enter the curry type
Vindaloo
Done
MENU: add (P)izza, add (C)urry, add (S)oft drink, (D)elete, (L)ist, (Q)uit
s
Enter the menu item number
789
Enter the size
Large
Enter the flavour
Coke
Enter whether it is a bottle or can
Bottle
Done
MENU: add (P)izza, add (C)urry, add (S)oft drink, (D)elete, (L)ist, (Q)uit
d
Enter the menu item number
456
Done
MENU: add (P)izza, add (C)urry, add (S)oft drink, (D)elete, (L)ist, (Q)uit
l
Pizza: 123, 12", Hand-tossed, Yes, Yes
Soft Drink: 789, Large, Coke, Bottle
Done
MENU: add (P)izza, add (C)urry, add (S)oft drink, (D)elete, (L)ist, (Q)uit
q

Free Chegg AnswerFor More Chemistry Notes and Helpful Content Subscribe Our YouTube Chanel - Chemistry Explain  

Free Chegg Answer

public class Pizza{
//class variables
int menuItemNumber;
String base,size;
boolean extraCheese,extraGarlic;
//constructor
public Pizza(int menuItemNumber, String size, String base, boolean extraCheese, boolean extraGarlic) {
this.menuItemNumber = menuItemNumber;
this.size = size;
this.base = base;
this.extraCheese = extraCheese;
this.extraGarlic = extraGarlic;
}
//tostring method
public String toString(){
return this.menuItemNumber + " "+ this.size+" "+this.base+" "+this.extraCheese+" "+this.extraGarlic;
}
}

--------------------------------------------------------------------------------------------------------------------------------------------

public class Curry {
//class variables
int menuItemNumber;
String curryType,size;
//constructor
public Curry(int menuItemNumber, String size, String curryType) {
this.menuItemNumber = menuItemNumber;
this.size = size;
this.curryType = curryType;
}
//to string method
public String toString(){
return this.menuItemNumber + " "+ this.size+" "+this.curryType;
}
}

-----------------------------------------------------------------------------------------------------------------

public class softDrink {
//class variables
int menuItemNumber;
String flavour,type,size;
//constructor
public softDrink(int menuItemNumber, String size, String flavour, String type) {
this.menuItemNumber = menuItemNumber;
this.size = size;
this.flavour = flavour;
this.type = type;
}
//toString method
public String toString(){
return this.menuItemNumber + " "+ this.size+" "+this.flavour+" "+this.type;
}
}

------------------------------------------------------------------------------------------------------------

import java.util.ArrayList;
import java.util.Scanner;

/**
*
* @author prmsh
*/
public class TestMenu extends Pizza{
public static void main(String args[]){
ArrayList yourOrder = new ArrayList(); //i stores order data
System.out.println("Welcome to Great International Food Court");
Scanner sc = new Scanner(System.in);
while(true){
//menu displaying
System.out.println("MENU: add (P)izza, add (C)urry, add (S)oft drink, (D)elete, (L)ist, (Q)uit");
String choice = sc.nextLine();
if(choice.equals("p") ||choice.equals("P")){ //this is for pizza
System.out.println("Enter menu item number");
int menuItem = sc.nextInt();
System.out.println("Enter size");
String size = sc.nextLine();
sc.nextLine();
System.out.println("Enter the base");
String base = sc.nextLine();
sc.nextLine();
System.out.println("Enter extra cheese");
boolean Cheese = sc.nextBoolean();
sc.nextLine();
System.out.println("Enter extra Garlic");
boolean Garlic = sc.nextBoolean();
Pizza pizza = new Pizza(menuItem,size,base,Cheese,Garlic);
yourOrder.add(pizza);
System.out.println("Done");
}
else if(choice.equals("c") ||choice.equals("C")){ //this is for curry
System.out.println("Enter menu item number");
int menuItem = sc.nextInt();
System.out.println("Enter size");
String size = sc.nextLine();
sc.nextLine();
System.out.println("Enter curry type");
String curryType = sc.nextLine();
sc.nextLine();
Curry curry = new Curry(menuItem,size,curryType);
yourOrder.add(curry);
System.out.println("Done");
}
else if(choice.equals("s") ||choice.equals("S")){//this is for soft drinks
System.out.println("Enter menu item number");
int menuItem = sc.nextInt();
System.out.println("Enter size");
String size = sc.nextLine();
sc.nextLine();
System.out.println("Enter flavour");
String flavour = sc.nextLine();
System.out.println("Enter whether it is a bottle or can");
String type = sc.nextLine();
sc.nextLine();
softDrink drink = new softDrink(menuItem,size,flavour,type);
yourOrder.add(drink);
System.out.println("Done");
}
else if(choice.equals("d") ||choice.equals("D")){ //to delte order
System.out.println("Enter posiyion to delete");
int number = sc.nextInt();
yourOrder.remove(number);
}
else if(choice.equals("l") ||choice.equals("L")){//to show all data
for(int i=0;i<yourOrder.size();i++){
System.out.println(yourOrder.get(i));
}
}
else if(choice.equals("q") ||choice.equals("Q")){ //safely exiting
System.out.println("Thank you!!1");
break;
}
}
}

public TestMenu(int menuItemNumber, String size, String base, boolean extraCheese, boolean extraGarlic) {
super(menuItemNumber, size, base, extraCheese, extraGarlic);
}
}

ChemistryExplain “#433 Write a JAVA program to store some in Computer science, Ba computer science, Berkeley computer science

Labels: , ,

Monday, October 26, 2020

#426 In the implementation of Singly linked

In the implementation of Singly linked - Computer Science

ChemistryExplain daily providing Q&A content “#426 In the implementation of Singly linked" in Computer science, Ba computer science, Berkeley computer science, Computer science associate degree jobs

ChemistryExplain “#426 In the implementation of Singly linked in Computer science, Ba computer science, Berkeley computer science
Get the Free Online Chemistry Q&A Questions And Answers with explain. To crack any examinations and Interview tests these Chemistry Questions And Answers are very useful. Here we have uploaded the Free Online Chemistry Questions. Here we are also given the all chemistry topic.

 ChemistryExplain team has covered all Topics related to inorganic, organic, physical chemistry, and others So, Prepare these Chemistry Questions and Answers with Explanation Pdf.

For More Chegg Questions

Free Chegg Question

 Q1) In the implementation of Singly linked list we had an integer variable called size that keeps track of how many elements in the list. Also, we have a reference “tail” that points to the last node in the list. You are asked to re-implement the concept of singly linked list without using variable size, and without using reference "tail”

a) What are the methods of the main operation of singly linked list that need to be changed? Rewrite them according to this change (only the methods that need to be changed). b) Will that affect the performance of any one of the main operations( size, isEmpty, first, last, addFirst, addLast, removeFirst, removeLast)? Explain.

Q2) Using a single queue (linkedQueue), re-implement the concept of Stack ADT, what is the complexity of the method push, pop, top, isEmpty, and size. You should not use any extra data structure.

Free Chegg AnswerFor More Chemistry Notes and Helpful Content Subscribe Our YouTube Chanel - Chemistry Explain  

Free Chegg Answer

Question 1:

a)

The method that need to be changed are int size(), void addLast(int data), Node last()

class Node {

int data;

Node next;

// Constructor

Node(int d) {

data = d;

next = null;

}

}

class LinkedList {

Node head; // head of list

// Method to insert a new node at the end

public void addLast( int data) {

// Create a new node with given data

Node new_node = new Node(data);

new_node.next = null;

// If the Linked List is empty,

// then make the new node as head

if ( this.head == null) {

this.head = new_node;

}

else {

// Else traverse till the last node

// and insert the new_node there

Node last = this.head;

while (last.next != null) {

last = last.next;

}

// Insert the new_node at last node

last.next = new_node;

}

}

// Method to get the size of the list

public int size() {

int size = 0;

Node temp = this.head;

while (temp != null) {

size++;

temp = temp.next;

}

return size;

}

// method to get the last element of the list

public Node last(){

  

Node temp = this.head;

while( temp.next != null){

temp = temp.next;

}

return temp;

}   

}

b) Yes, It will affect the following operations:

1. size:

If we had the size variable in the list class then we can return the size value in O(1) time. But since we have no size variable we have to traverse the complete list and have to count the size of the list and return it. This operation takes O(n) time (where n is the number if node in the list) as we have to traverse the complete LinkedList once.

2. addLast:

If we had the tail node then we can add the new node directly to the tail of the list in O(1) time complexity. But as we are not having the tail reference we have to traverse the complete LinkedList to get to the tail of the LinkedList and add the node there. This operation takes O(n) time (where n is the number if node in the list) as we have to traverse the complete LinkedList once.

Question 2:

import java.util.*;

class Stack {

// Two inbuilt queues

Queue<Integer> q1 = new LinkedList<Integer>();

Queue<Integer> q2 = new LinkedList<Integer>();

// To maintain current number of

// elements

int curr_size;

Stack()

{

curr_size = 0;

}

void push(int x)

{

curr_size++;

// Push x first in empty q2

q2.add(x);

// Push all the remaining

// elements in q1 to q2.

while (!q1.isEmpty()) {

q2.add(q1.peek());

q1.remove();

}

// swap the names of two queues

Queue<Integer> q = q1;

q1 = q2;

q2 = q;

}

void pop()

{

// if no elements are there in q1

if (q1.isEmpty())

return;

q1.remove();

curr_size--;

}

int top()

{

if (q1.isEmpty())

return -1;

return q1.peek();

}

int size() {

return curr_size;

}

}

Labels: , ,