Finding A gene in DNA Solution Quiz 1 --Java Programming: Solving Problems with Software



a
a
a
a

Finding A URl on a Page Java Code --Java Programming: Solving Problems with Software


/**
 * Write a description of URLFINDER here.
 *
 * @author (your name)
 * @version (a version number or a date)
 */
import edu.duke.*;
import java.io.*;
public class URLFINDER
{
    public void asd(){
        URLResource file = new URLResource("http://www.dukelearntoprogram.com/course2/data/manylinks.html");
        for ( String item : file.words() ) {
            String itemLower = item.toLowerCase();
            int pos = itemLower.indexOf("youtube.com");
            if ( pos != -1 ) {
                int beg = item.lastIndexOf("\"", pos);
                int end = item.indexOf("\"", pos + 1);
                System.out.println(item.substring(beg + 1, end));
        }
    }
  }
}

Code For finding aProtien string in a DNA --Java Programming: Solving Problems with Software

import edu.duke.*;
import java.io.*;
public class TagFinder{
    public String findProtein(String dna){
        int start = dna.indexOf("atg");
        int stop = dna.indexOf("tag", start +3);
        if (start == -1){
            return "no starton protein found";
        }
      
        if ((stop-start)%3==0){
            return dna.substring(start,stop+3);
        }
        else{
            return"not not a protein because of Divisible factor";
        }
    }
    public void testing()
    {
        String a = "cccatggggtttaaataataataggagagagagagagagttt";
        String ap = "atggggtttaaataataatag";
        //String a = "sdafsdfsdatgccctagdsfsdfgsffd";
        //String ap = "atgccctag";
        //String a = "atgcctag";
        //String ap = "";
        //String a = "ATGCCCTAG";
        //String ap = "ATGCCCTAG";
        String result = findProtein(a);
        if (ap.equals(result)){
            System.out.println("sucess for "+ap + "length " + ap.length());
        }
        else{
            System.out.println("mistake for input:"+a);
            System.out.println("got:"+result);
            System.out.println("not:"+ap);
        }
    }
    public void realTesting(){
      DirectoryResource dr = new DirectoryResource();
      for (File f : dr.selectedFiles()){
        FileResource fr = new FileResource(f);
        String s =fr.asString();
        System.out.println("read "+s.length()+" character");
        String result = findProtein(s);
        System.out.println("found "+ result);
        }
    }
}

Iterables In Java Main Quiz --Java Programming: Solving Problems with Software


 

Batch GrayScale Images Practice Quiz Solutions --Java Programming: Solving Problems with Software


Converting Images to Gray Scale And Saving A Copy Of Them(Multiple) -- Java Programming: Solving Problems with Software


import edu.duke.*;
import java.io.File;
public class GrayScaleConverter {

    //started with the image i wanted(inImage)

    public ImageResource makeGray(ImageResource inImage){

    //I Made a blank image of the same size

        ImageResource outImage = new ImageResource(inImage.getWidth(),inImage.getHeight());

    //for each pixelin outImage

        for(Pixel pixel : outImage.pixels()){

    //look at the corresponding pixel in inImage

            Pixel inPixel = inImage.getPixel(pixel.getX(),pixel.getY());

    //compute inPixel's red + inPixel's blue + inpixel's green

    //divide that sum by 3(call it average)

    int average = (inPixel.getRed()+inPixel.getGreen()+inPixel.getBlue())/3;

    //set pixel's red to average

    pixel.setRed(average);

    //set pixel's green to average

    pixel.setGreen(average);

    //set pixel's blur to average

    pixel.setBlue(average);

    }

     return outImage;

    }  
   

    public void SelectAndConvert(){

        DirectoryResource dr = new DirectoryResource();

        for (File f : dr.selectedFiles()){
        ImageResource inImage = new ImageResource(f);
        ImageResource gray = makeGray(inImage);
        String fname = inImage.getFileName();
        String newfname = "copy-" + fname;
        gray.setFileName(newfname);
        gray.draw();
        gray.save();
        }

    } 

}

Batch Gratscale Image Code --Java Programming: Solving Problems with Software


import edu.duke.*;
import java.io.File;
public class GrayScaleConverter {

    //started with the image i wanted(inImage)

    public ImageResource makeGray(ImageResource inImage){

    //I Made a blank image of the same size

        ImageResource outImage = new ImageResource(inImage.getWidth(),inImage.getHeight());

    //for each pixelin outImage

        for(Pixel pixel : outImage.pixels()){

    //look at the corresponding pixel in inImage

            Pixel inPixel = inImage.getPixel(pixel.getX(),pixel.getY());

    //compute inPixel's red + inPixel's blue + inpixel's green

    //divide that sum by 3(call it average)

    int average = (inPixel.getRed()+inPixel.getGreen()+inPixel.getBlue())/3;

    //set pixel's red to average

    pixel.setRed(average);

    //set pixel's green to average

    pixel.setGreen(average);

    //set pixel's blur to average

    pixel.setBlue(average);

    }

     return outImage;

    }  

    public void SelectAndConvert(){

        DirectoryResource dr = new DirectoryResource();

        for (File f : dr.selectedFiles()){
        ImageResource inImage = new ImageResource(f);
        ImageResource gray = makeGray(inImage);
        gray.draw();
        }

    } 

}

కరోనా కోవిడ్ -19 గురించి ఏ వికీపీడియా మీకు చెప్పలేము?

కరోనా కోవిడ్ -19 గురించి ఏ వికీపీడియా మీకు చెప్పలేము? మిమ్మల్ని మీరు రక్షించుకోండి  Your మీ చేతులను తరచుగా కడగాలి Eyes మీ కళ్ళు, న...