Questions
Please construct a code following the instructions below Part 3 – infixEvaluator method You are required...

Please construct a code following the instructions below

Part 3 – infixEvaluator method

You are required to implement the following method:  

public static double infixEvaluator(String line)

This function first needs to tokenize the input expression (in the form of a String and stored in input variable “line”). You can tokenize the input expression by creating an object of StringSplitter and passing it the String as follows. StringSplitter uses a queue to accomplish the tokenization (see the class for details).

StringSplitter data = new StringSplitter(line);

Next, create your two stacks. Remember one will contain the operators and the other one will include the operands. Define them as follows:

Stack<String> operators = new Stack<String>();  

Stack<Double> operands = new Stack<Double>();

Before we continue further in this method, it will be helpful to consider helper methods we might need (which will make our job easier :-).

Skeleton of the code below:

/**

* give a description of the purpose of this method

* @param line fill in

* @return fill in

*/

public static double infixEvaluator(String line){

return 0.0; // placeholder

}

In: Computer Science

Problem: Write a program that takes your weight in pounds as input and then prints how...

Problem: Write a program that takes your weight in pounds as input and then prints how much you will weigh on Moon and Mars. The formula to convert weight on the Earth to weight on Moon and Mars are given below:

  • Weight on Moon = weight on Earth * 0.165
  • Weight on Mars = weight on Earth * 3.711 / 9.81

You should name the program as weight_watcher.py. The output should look like as shown below:

In: Computer Science

Lab # 4 Multidimensional Arrays Please write in JAVA. Programming Exercise 8.5 (Algebra: add two matrices)...

Lab # 4 Multidimensional Arrays

Please write in JAVA.

Programming Exercise 8.5 (Algebra: add two matrices)

Write a method to add two matrices. The header of the method is as follows:

public static double[][] addMatrix(double[][] a, double[][] b

In order to be added, the two matrices must have the same dimensions and the same or compatible types of elements. Let c be the resulting matrix. Each element cij is aij + bij. For example, for two 3 * 3 matrices a and b, c is

Write a test program that prompts the user to enter two 3 * 3 matrices and displays their sum. Here is a sample run

Example run:

Enter matrix1: 1 2 3 4 5 6 7 8 9 (enter)

Enter martix2: 0 2 4 1 4.5 2.2 1.1 4.3 5.2 (enter)

The matrices are added as follows:

1.0 2.0 3.0              0.0 2.0 4.0            1.0 4.0 7.0

4.0 5.0 6.0        +    1.0 4.5 2.2     =      5.0 9.5 8.2

7.0 8.0 9.0              1.1 4.3 5.2           8.1 12.3 14.2

Programming Exercise 8.6 (Algebra: multiply two matrices)

Write a method to multiply two matrices. The header of the method is:

public static double[][] multiplyMatrix(double[][] a, double[][] b)

To multiply matrix a by matrix b, the number of columns in a must be the same as the number of rows in b, and the two matrices must have elements of the same or compatible types. Let c be the result of the multiplication. Assume the column size of matrix a is n. Each element cij is ai1 * b1j + ai2 * b2j + c + ain * bnj. For example, for two 3 * 3 matrices a and b, c is

where cij = ai1 * b1j + ai2 * b2j + ai3 * b3j. Write a test program that prompts the user to enter two 3 * 3 matrices and displays their product. Here is a sample run:

Example run:

Enter matrix1: 1 2 3 4 5 6 7 8 9 (enter)

Enter matrix2: 0 2 4 1 4.5 2.2 1.1 4.3 5.2 (enter)

The multiplication of the matrices is

1 2 3           0 2.0 4.0               5.3 23.9 24

4 5 6     *     1 4.5 2.2     =       11.6 56.3 58.2

7 8 9           1.1 4.3 5.2            17.9 88.7 92.4

In: Computer Science

discuss the local and global impact of computing on individuals, organizations, and society

discuss the local and global impact of computing on individuals, organizations, and society

In: Computer Science

Answer the following questions about Starvation. Explain what it means for a job to experience Starvation....

Answer the following questions about Starvation.

  1. Explain what it means for a job to experience Starvation.
  2. How is starvation similar to or different from Deadlock or Livelock?
  3. What can an operating system do to prevent a starving job from "remaining in the system forever"?

In: Computer Science

public class GroceryShopping {    //declared variable    private String vegetableName;    private String fruitName;   ...

public class GroceryShopping
{
   //declared variable
   private String vegetableName;
   private String fruitName;
   private double vegetablePrice;
   private double fruitPrice;
   private double vegetableOrdered;
   private double fruitOrdered;
  
   //declared constants
   public static final double SERVICE_RATE =0.035;
   public static final double DELIVERY_FEE=5;
  
   public GroceryShopping( String vegetableName, String fruitName, double vegetablePrice, double fruitPrice)
   {
       this.vegetableName = vegetableName;
       this.fruitName = fruitName;
       this.vegetablePrice = vegetablePrice;
       this.fruitPrice = fruitPrice;
       this.vegetableOrdered = vegetableOrdered;
       this.fruitOrdered=fruitOrdered;
   }
   public String getVegetableName()
   {
       return vegetableName;
   }
  
   public void setVegetableName(String vegetableName)
   {
       this.vegetableName = vegetableName;
   }
  
   public String getFruitName()
   {
       return fruitName;
   }
  
   public void setFruitName(String fruitName)
   {
       this.fruitName = fruitName;
   }
  
   public double getVegetablePrice()
   {
       return vegetablePrice;
   }
  
   public void setVegetablePrice(double vegetablePrice)
   {
       this.vegetablePrice = vegetablePrice;
   }
  
   public double getFruitPrice()
   {
       return fruitPrice;
   }
  
   public void setFruitPrice(double fruitPrice)
   {
       this.fruitPrice = fruitPrice;
   }
  
   public double getVegetableOrdered()
   {
       return vegetableOrdered;
   }
  
   public void setVegetableOrdered(double vegetableOrdered)
   {
       this.vegetableOrdered = vegetableOrdered;
   }
  
   public double getFruitOrdered()
   {
       return fruitOrdered;
   }
  
   public void setFruitOrdered(double fruitOrdered)
   {
       this.fruitOrdered = fruitOrdered;
   }
  
  
   public double calculateSubtotal()
   {
       double calculateSubtotal=(vegetablePrice*vegetableOrdered)+(fruitPrice*fruitOrdered);
       return calculateSubtotal;
   }
  
   public double calculateAdditionalFee()
   {
       double calculateAdditionalFee=calculateSubtotal()* SERVICE_RATE + DELIVERY_FEE;
       return calculateAdditionalFee;
   }
  
   public void displayOrderSummary()
   {
       double totalBill=calculateSubtotal()+calculateAdditionalFee();
       System.out.println("--------------------------------------");
       System.out.println("Grocery Shopping Order Summary");
       System.out.println("\nName"+"\t\t\tPrice Per Pound");
       System.out.println("Sub-total:"+"\t\t$"+calculateSubtotal());
       System.out.println("Additional Fee:"+"\t\t$"+calculateAdditionalFee());
       System.out.println("Total Bill:"+"\t\t$"+totalBill);
       System.out.println("--------------------------------------");
      
   }
  
  
  
  
  
  
  
  
  
}

public class GroceryShoppingApp
{

  
   /**
   * @param args
   */
   public static void main(String[] args)
   {
       Scanner input=new Scanner(System.in);
      
  
       displayTable1();
       System.out.println("\nPlease select the vegetable from Table 1: ");
       String vegetableName=input.next();
       System.out.println("please enter the price of the selected vegetable: ");
       double vegetablePrice=input.nextDouble();
      
       displayTable2();
       System.out.println("\nPlease select the fruit from Table 2");
       String fruitName =input.next();
       System.out.println("Please enter the price of the selected fruit:");
       double fruitPrice =input.nextDouble();
       GroceryShopping gs =new GroceryShopping(vegetableName, fruitName, vegetablePrice, fruitPrice);
      
      
      
       System.out.println("\n--------------------------------------");
       System.out.println("Grocery Shopping Menu");
       System.out.println("\nName"+"\t\tPrice Per Pound");
       System.out.println(gs.getVegetableName()+"\t"+gs.getVegetablePrice());
       System.out.println(gs.getFruitName()+"\t\t"+gs.getFruitPrice());
       System.out.println("--------------------------------------\n");
       System.out.println("\nEnter the pounds of "+ gs.getVegetableName()+" ordered: ");
       double vegetableOrdered=input.nextDouble();
       System.out.println("Enter the pounds of "+ gs.getFruitName()+" ordered: ");
       double fruitOrdered=input.nextDouble();      
  
       System.out.println("\n\n\n--------------------------------------");
       System.out.println("Grocery Shopping Order Summary");
       System.out.println("\nName"+"\t\tPrice Per Pound");
       System.out.println(vegetableName+"\t"+vegetablePrice);
       System.out.println(fruitName+"\t\t"+fruitPrice);
      
       gs.displayOrderSummary();
      
       input.close();
      

      
      

   }

   private static void displayTable1()
   {
   System.out.println("Vegetable Name\t\t"+"Price Per Pound");
   System.out.println("Broccoli\t\t"+"$3.12");
   System.out.println("Yellow Onion\t\t"+"$1.15");
   System.out.println("Chill Pepper\t\t"+"$4.58");
   System.out.println("Greens Bundle\t\t"+"$2.82");
   System.out.println("--------------------------------------");
   System.out.println("Table 1: Vegetable names with corresponding price per pound");
   }
  
  
   private static void displayTable2()
   {
   System.out.println("\n--------------------------------------");
   System.out.println("Fruit Name\t\t"+"Price Per Pound");
   System.out.println("Apple\t\t\t"+"$1.73");
   System.out.println("Grape\t\t\t"+"$2.15");
   System.out.println("Key Lime\t\t"+"$2.58");
   System.out.println("Navel Orange\t\t"+"$1.86");
   System.out.println("--------------------------------------");
   System.out.println("Table 2: Fruit names with corresponding price per pound ");
   }
  
}
I have two question

1) My Sub-Total fee is always is zero, no matter what i input.

2)When i input the vegetable and fruit name, only the apple , Grape and Broccoli are working. The others always shows error, when i try to input them.

In: Computer Science

I want to create an Android mobile application, an application that provides courses for students ......

I want to create an Android mobile application, an application that provides courses for students ... I want advice for safety and security, what are its requirements ... and what are the yooze case for this application and the Functional requirements of your opinion

In: Computer Science

MATLAB language; ... Boyle's law of gases says that: P1V1 = P2V2 Make a program (script)...

MATLAB language;

...

Boyle's law of gases says that:

P1V1 = P2V2

Make a program (script) that calculates any of the 4 parameters, based on the elements that the user decides, that is:

P1 = P2V2 / V1 - ask for the data that is needed. P2, V2, V1

V1 = P2V2 / P1 - ask for the data that is needed. P2, V2, P1

P2 = P1V1 / V2 - ask for the data that is needed. P1, V2, V1

V2 = P1V1 / P2 - ask for the data that is needed. P1, P2, V1

REMEMBER THAT FROM THAT ELECTION, THE REQUIRED VALUES ARE ASKED

In: Computer Science

What is the output of the following program? Slightly modify the program so that: [Pts. 10]...

  1. What is the output of the following program? Slightly modify the program so that: [Pts. 10]
    1. The Parent process calculates the val such a way that its value is 20 and it prints “This is parent process and val = 20”. Also, slightly modify
    2. The child process calculates the val such a way that its value is 25 and it prints “This is child process and val = 25”.

int main() {

int val = 15;

int pid;

if (pid = fork()){

wait(pid);

printf(“This is parent process and val = “);

}

else{

printf(“This is child process and val = “);

val++;

}

printf("%d\n", val);

return val;

}

In: Computer Science

//2.-------------------------------------------------------------- Given an array of size N, what is the complexity? int m = A[0]; for...

//2.--------------------------------------------------------------
Given an array of size N, what is the complexity?
int m = A[0];
for (int i=1; i<N; i++)
{ if (A[i] > m) m = A[i]; }
int k = 0;
for (int i=0; i<N; i++)
{ if (A[i] == m) k++; }

What is a (name one) most frequent operation performed?______________________

Expression showing the number of times it is performed ___________

Time Complexity in Big-O Notation O( ) _____________________________________________________

//3.--------------------------------------------------------------
int mult(int N, int M)
{
   int s = 0;
   while (N > 0)
   {
       s = s + M;
       N = N-1;
   }
   return s;
}

What is a (name one) most frequent operation performed?______________________

Expression showing the number of times it is performed___________

Time Complexity in Big-O Notation O( )

In: Computer Science

Managing Linux Servers (Apache, Samba, DNS, 1. What is the Apache directive that specifies the base...

Managing Linux Servers (Apache, Samba, DNS,

1. What is the Apache directive that specifies the base directory for configuration and log files?

2. Once you’ve modified httpd.conf, what command would make Apache reread this file, without kicking off currently connected users?

3. What directive specifies the TCP/IP port associated with Apache?

4. What ports must be open for a Samba server to work with remote systems?

6. What samba configuration steps are required for mapping a Windows user to a Linux user?

7. From a nfs server, how would you allow readonly access to /opt for any system in example.com?

8. How would you instruct a DNS server to respond only to queries from the 137.44.* IP range?

9. What is pNFS ?

10. What do you understand by "nfsstat --nfs --server -3" command?

11. How to retrieve a list of clients connected to the NFS server ?

14. What is a difference between Apache and Nginx web server?

15. Explain Bind chroot environment ?

20. Can Samba be a member of more than one workgroup at the same time?

In: Computer Science

AI Question: Consider a simple reflex agent maps a state to a single action. Suppose there...

AI Question:

Consider a simple reflex agent maps a state to a single action. Suppose there exists a world with S states and A possible actions in any of these states. How many distinct simple reflex agents can exist in such a world? Or equivalently, how many functions f can there be for some f(s) = a?

In: Computer Science

Programming 3: Multi-Way Branching Shipping Charges The Fast Freight Shipping Company charges the following rates: Given...

Programming 3: Multi-Way Branching

Shipping Charges

The Fast Freight Shipping Company charges the following rates:

  • Given the Weight of Package (in Kilograms), use the following Rate ($) per 500 Miles Shipped.

  • 2 kg or less = $1.10 per 500 Miles Shipped

  • Over 2 kg but not more than 6 kg = $2.20 per 500 Miles Shipped

  • Over 6 kg but not more than 10 kg = $3.70 per 500 Miles Shipped

  • Over 10 kg but not more than 20 kg = $4.80 per 500 Miles Shipped

Write a program that reads the weight of the package and the distance it is to be shipped, and then displays the charges to two decimal points.

  • Input Validation:
  • Do not accept values of 0 or less for the weight of the package.
    • Print "ILLEGAL WEIGHT: BELOW MINIMUM"
  • Do not accept weights of more than 20 kg (this is the maximum weight the company will ship).
    • Print "ILLEGAL WEIGHT: ABOVE MAXIMUM"
  • Do not accept distances of less than 10 miles or more than 3,000 miles. These are the company’s minimum and maximum shipping distances.
    • Print "ILLEGAL DISTANCE"

I got stuck here:

#include
using namespace std;

int main(){
int i=0,miles;
   double j,weight,cost,distance;

   cin>>weight;
      if(weight<=0){
         cout<< "ILLEGAL WEIGHT: BELOW MINIMUM" << endl;
      }
      else(weight>20){
         cout<< "ILLEGAL WEIGHT: ABOVE MAXIMUM" << endl;
      }
       

   cin>>distance;
      while(distance<10 || distance >3000){
         cout<< "ILLEGAL DISTANCE" << endl;
      }
   i=miles/500;
   j=miles%500;

   if(j>0){
       i=i+1;
   }
   if(weight<=2){
       cost=i*1.10;
   }
   else if(weight>2 && weight<=6){
       cost=i*2.20;
   }
   else if(weight>6 && weight<=10){
       cost=i*3.70;
   }
   else if(weight>10 && weight<=20){
       cost=i*4.80;
   }
   cout<<"Cost of Shipping: " << cost;
   return 0;
}

Random inputs are....

Input : -1 2000

Expected inputs are : ILLEGAL WEIGHT: BELOW MINIMUM

Input: 1 5000

Expected output : ILLEGAL DISTANCE

input: 2 2000

Expected output : 4.40 (<--| enter symbol)

Please revise and let me know what i did wrong.....

In: Computer Science

Python Create Loop 1 = 1 1 + 2 = 3 1 + 2 + 3...

Python Create Loop

    1 = 1
    1 + 2 = 3 
    1 + 2 + 3 = 6
    1 + 2 + 3 + 4 = 10
    1 + 2 + 3 + 4 + 5 = 15

Create a loop in python that makes this pattern

In: Computer Science

Can someone tell me how to fix warning msg in my code of C ++? I...

Can someone tell me how to fix warning msg in my code of C ++?

I got run-time error for this question please help me asap!

Errors are:
In function 'void bfs(int, int)':
warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
 for(int j = 0; j < adj[pppp].size(); j++){
                  ^
In function 'int main()':
warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
 scanf("%d %d %d %d %d", &a, &q, &c, &N, &m);
                                            ^
warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
 scanf("%d %d", &fir, &bbb);
                         ^

#include <iostream>

#include <stdio.h>

#include <vector>

#include <algorithm>

#include <queue>

int min(int n,int arr[]){

int m=arr[0];

for(int i=1;i<n;i++)

if(m>arr[i])

m=arr[i];

return m;

}

using namespace std;

const int Max_max = 404040;

const int INF = 1e7;

int sum[Max_max];

int a,q,c,N,m,fir;

vector<int> adj[Max_max];

void bfs(int money, int start_node){

bool hello[Max_max];

for(int i=0; i<=N; i++)

hello[i] = false;

queue<int> q;

q.push(start_node);

hello[start_node] = true;

int distance = 1;

do{

int size = q.size();

for(int i = 0; i < size; i++){

int pppp = q.front(); q.pop();

for(int j = 0; j < adj[pppp].size(); j++){ //error undeclared identifier 'ppp_city'

int next = adj[pppp][j];

if(hello[next])

continue;

sum[pppp] += money * distance;

hello[next] = true;

q.push(next);

}

}

distance++;

} while (q.size() > 0);

}

int main(){

scanf("%d %d %d %d %d", &a, &q, &c, &N, &m);

for(int i=0; i < m; i++){

int aaa, bbb;

scanf("%d %d", &fir, &bbb);

adj[aaa].push_back(bbb);

adj[bbb].push_back(aaa);

}

bfs(a,1);

bfs(q,2);

bfs(c,N);

int fin = INF;

for(int i = 1; i <= N; i++)

fin = min(fin, sum); //error no matching function to call min

printf("%d",fin);

return 0;

}

In: Computer Science